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.
-
#idle(*masks) ⇒ Object
Waits until there is a noteworthy change in one or more of MPD’s subsystems.
-
#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.
126 127 128 |
# File 'lib/ruby-mpd/plugins/information.rb', line 126 def consume? return status[:consume] end |
#crossfade ⇒ Integer
Returns Crossfade in seconds.
116 117 118 |
# File 'lib/ruby-mpd/plugins/information.rb', line 116 def crossfade return status[:xfade] end |
#current_song ⇒ MPD::Song
Get the currently playing song
17 18 19 |
# File 'lib/ruby-mpd/plugins/information.rb', line 17 def current_song Song.new send_command :currentsong end |
#idle(*masks) ⇒ Object
Waits until there is a noteworthy change in one or more of MPD’s subsystems. As soon as there is one, it lists all changed systems in a line in the format ‘changed: SUBSYSTEM’, where SUBSYSTEM is one of the following:
-
database: the song database has been modified after update.
-
update: a database update has started or finished. If the database was modified during the update, the database event is also emitted.
-
stored_playlist: a stored playlist has been modified, renamed, created or deleted
-
playlist: the current playlist has been modified
-
player: the player has been started, stopped or seeked
-
mixer: the volume has been changed
-
output: an audio output has been enabled or disabled
-
options: options like repeat, random, crossfade, replay gain
-
sticker: the sticker database has been modified.
-
subscription: a client has subscribed or unsubscribed to a channel
-
message: a message was received on a channel this client is subscribed to; this event is only emitted when the queue is empty
If the optional masks
argument is used, MPD will only send notifications when something changed in one of the specified subsytems.
44 45 46 |
# File 'lib/ruby-mpd/plugins/information.rb', line 44 def idle(*masks) send_command(:idle, *masks) end |
#paused? ⇒ Boolean
Is MPD paused?
94 95 96 |
# File 'lib/ruby-mpd/plugins/information.rb', line 94 def paused? return status[:state] == :pause end |
#playing? ⇒ Boolean
Is MPD playing?
100 101 102 |
# File 'lib/ruby-mpd/plugins/information.rb', line 100 def return status[:state] == :play end |
#playlist_version ⇒ Integer
Returns Current playlist version number.
121 122 123 |
# File 'lib/ruby-mpd/plugins/information.rb', line 121 def playlist_version return status[:playlist] end |
#random? ⇒ Boolean
Returns true if random playback is currently enabled,
136 137 138 |
# File 'lib/ruby-mpd/plugins/information.rb', line 136 def random? return status[:random] end |
#repeat? ⇒ Boolean
Returns true if repeat is enabled,
141 142 143 |
# File 'lib/ruby-mpd/plugins/information.rb', line 141 def repeat? return status[:repeat] end |
#single? ⇒ Boolean
Returns true if single is enabled.
131 132 133 |
# File 'lib/ruby-mpd/plugins/information.rb', line 131 def single? return 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
86 87 88 |
# File 'lib/ruby-mpd/plugins/information.rb', line 86 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
72 73 74 |
# File 'lib/ruby-mpd/plugins/information.rb', line 72 def status send_command :status end |
#stopped? ⇒ Boolean
Returns Is MPD stopped?.
105 106 107 |
# File 'lib/ruby-mpd/plugins/information.rb', line 105 def stopped? return status[:state] == :stop end |
#volume ⇒ Integer
Gets the volume level.
111 112 113 |
# File 'lib/ruby-mpd/plugins/information.rb', line 111 def volume return status[:volume] end |