Module: MPD::Plugins::Information

Included in:
MPD
Defined in:
lib/ruby-mpd/plugins/information.rb

Overview

Informational commands regarding MPD’s current status.

Instance Method Summary collapse

Instance Method Details

#clearerrorBoolean

Clears the current error message reported in status (also accomplished by any command that starts playback).

Returns:

  • (Boolean)

    returns true if successful.



10
11
12
# File 'lib/ruby-mpd/plugins/information.rb', line 10

def clearerror
  send_command :clearerror
end

#consume?Boolean

Returns true if consume is enabled.

Returns:

  • (Boolean)


129
130
131
# File 'lib/ruby-mpd/plugins/information.rb', line 129

def consume?
  status[:consume]
end

#crossfadeInteger

Returns Crossfade in seconds.

Returns:

  • (Integer)

    Crossfade in seconds.



119
120
121
# File 'lib/ruby-mpd/plugins/information.rb', line 119

def crossfade
  status[:xfade]
end

#current_songMPD::Song?

Get the currently playing song

Returns:

  • (MPD::Song)
  • (nil)

    if there is no song playing



18
19
20
21
22
# File 'lib/ruby-mpd/plugins/information.rb', line 18

def current_song
  hash = send_command :currentsong
  # if there is no current song (we get true, then return nil)
  hash.is_a?(TrueClass) ? nil : Song.new(hash)
end

#paused?Boolean

Is MPD paused?

Returns:

  • (Boolean)


97
98
99
# File 'lib/ruby-mpd/plugins/information.rb', line 97

def paused?
  status[:state] == :pause
end

#playing?Boolean

Is MPD playing?

Returns:

  • (Boolean)


103
104
105
# File 'lib/ruby-mpd/plugins/information.rb', line 103

def playing?
  status[:state] == :play
end

#playlist_versionInteger

Returns Current playlist version number.

Returns:

  • (Integer)

    Current playlist version number.



124
125
126
# File 'lib/ruby-mpd/plugins/information.rb', line 124

def playlist_version
  status[:playlist]
end

#random?Boolean

Returns true if random playback is currently enabled,

Returns:

  • (Boolean)


139
140
141
# File 'lib/ruby-mpd/plugins/information.rb', line 139

def random?
  status[:random]
end

#repeat?Boolean

Returns true if repeat is enabled,

Returns:

  • (Boolean)


144
145
146
# File 'lib/ruby-mpd/plugins/information.rb', line 144

def repeat?
  status[:repeat]
end

#single?Boolean

Returns true if single is enabled.

Returns:

  • (Boolean)


134
135
136
# File 'lib/ruby-mpd/plugins/information.rb', line 134

def single?
  status[:single]
end

#statsHash

Statistics.

  • artists: number of artists

  • songs: number of albums

  • uptime: daemon uptime in seconds

  • db_playtime: sum of all song times in the db

  • db_update: last db update in a Time object

  • playtime: time length of music played

Returns:

  • (Hash)

    MPD statistics.



89
90
91
# File 'lib/ruby-mpd/plugins/information.rb', line 89

def stats
  send_command :stats
end

#statusHash

MPD status: volume, time, modes…

  • volume: 0-100

  • repeat: true or false

  • random: true or false

  • single: true or false

  • consume: true or false

  • playlist: 31-bit unsigned integer, the playlist version number

  • playlistlength: integer, the length of the playlist

  • state: :play, :stop, or :pause

  • song: playlist song number of the current song stopped on or playing

  • songid: playlist songid of the current song stopped on or playing

  • nextsong: playlist song number of the next song to be played

  • nextsongid: playlist songid of the next song to be played

  • time: total time elapsed (of current playing/paused song)

  • elapsed: Total time elapsed within the current song, but with higher resolution.

  • bitrate: instantaneous bitrate in kbps

  • xfade: crossfade in seconds

  • mixrampdb: mixramp threshold in dB

  • mixrampdelay: mixrampdelay in seconds

  • audio: [sampleRate, bits, channels]

  • updating_db: job id

  • error: if there is an error, returns message here

Returns:

  • (Hash)

    Current MPD status.



75
76
77
# File 'lib/ruby-mpd/plugins/information.rb', line 75

def status
  send_command :status
end

#stopped?Boolean

Returns Is MPD stopped?.

Returns:

  • (Boolean)

    Is MPD stopped?



108
109
110
# File 'lib/ruby-mpd/plugins/information.rb', line 108

def stopped?
  status[:state] == :stop
end

#volumeInteger

Gets the volume level.

Returns:

  • (Integer)


114
115
116
# File 'lib/ruby-mpd/plugins/information.rb', line 114

def volume
  status[:volume]
end