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
-
#clearerror ⇒ Boolean
Clears the current error message reported in status (also accomplished by any command that starts playback).
-
#consume? ⇒ Boolean
Returns true if consume is enabled.
-
#crossfade ⇒ Integer
Crossfade in seconds.
-
#current_song ⇒ MPD::Song?
Get the currently playing song.
-
#paused? ⇒ Boolean
Is MPD paused?.
-
#playing? ⇒ Boolean
Is MPD playing?.
-
#playlist_version ⇒ Integer
Current playlist version number.
-
#random? ⇒ Boolean
Returns true if random playback is currently enabled,.
-
#repeat? ⇒ Boolean
Returns true if repeat is enabled,.
-
#single? ⇒ Boolean
Returns true if single is enabled.
-
#stats ⇒ Hash
Statistics.
-
#status ⇒ Hash
MPD status: volume, time, modes…
-
#stopped? ⇒ Boolean
Is MPD stopped?.
-
#volume ⇒ Integer
Gets the volume level.
Instance Method Details
#clearerror ⇒ Boolean
Clears the current error message reported in status (also accomplished by any command that starts playback).
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.
129 130 131 |
# File 'lib/ruby-mpd/plugins/information.rb', line 129 def consume? status[:consume] end |
#crossfade ⇒ Integer
Returns Crossfade in seconds.
119 120 121 |
# File 'lib/ruby-mpd/plugins/information.rb', line 119 def crossfade status[:xfade] end |
#current_song ⇒ MPD::Song?
Get the currently playing song
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?
97 98 99 |
# File 'lib/ruby-mpd/plugins/information.rb', line 97 def paused? status[:state] == :pause end |
#playing? ⇒ Boolean
Is MPD playing?
103 104 105 |
# File 'lib/ruby-mpd/plugins/information.rb', line 103 def status[:state] == :play end |
#playlist_version ⇒ Integer
Returns 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,
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,
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.
134 135 136 |
# File 'lib/ruby-mpd/plugins/information.rb', line 134 def single? status[:single] end |
#stats ⇒ Hash
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
89 90 91 |
# File 'lib/ruby-mpd/plugins/information.rb', line 89 def stats send_command :stats end |
#status ⇒ Hash
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
75 76 77 |
# File 'lib/ruby-mpd/plugins/information.rb', line 75 def status send_command :status end |
#stopped? ⇒ Boolean
Returns Is MPD stopped?.
108 109 110 |
# File 'lib/ruby-mpd/plugins/information.rb', line 108 def stopped? status[:state] == :stop end |
#volume ⇒ Integer
Gets the volume level.
114 115 116 |
# File 'lib/ruby-mpd/plugins/information.rb', line 114 def volume status[:volume] end |