module MPD::Plugins::Information
Informational commands regarding MPD’s current status.
Public Instance Methods
Clears the current error message reported in status (also accomplished by any command that starts playback).
@macro returnraise
# File lib/ruby-mpd/plugins/information.rb, line 10 def clearerror send_command :clearerror end
Returns true if consume is enabled.
# File lib/ruby-mpd/plugins/information.rb, line 129 def consume? status[:consume] end
@return [Integer] Crossfade in seconds.
# File lib/ruby-mpd/plugins/information.rb, line 119 def crossfade status[:xfade] end
Get the currently playing song
@return [MPD::Song] @return [nil] if there is no song playing
# 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(self, hash) end
Is MPD
paused? @return [Boolean]
# File lib/ruby-mpd/plugins/information.rb, line 97 def paused? status[:state] == :pause end
Is MPD
playing? @return [Boolean]
# File lib/ruby-mpd/plugins/information.rb, line 103 def playing? status[:state] == :play end
@return [Integer] Current playlist version number.
# File lib/ruby-mpd/plugins/information.rb, line 124 def playlist_version status[:playlist] end
Returns true if random playback is currently enabled,
# File lib/ruby-mpd/plugins/information.rb, line 139 def random? status[:random] end
Returns true if repeat is enabled,
# File lib/ruby-mpd/plugins/information.rb, line 144 def repeat? status[:repeat] end
Returns true if single is enabled.
# File lib/ruby-mpd/plugins/information.rb, line 134 def single? status[:single] end
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
@return [Hash] MPD
statistics.
# File lib/ruby-mpd/plugins/information.rb, line 89 def stats send_command :stats end
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
@return [Hash] Current MPD
status.
# File lib/ruby-mpd/plugins/information.rb, line 75 def status send_command :status end
@return [Boolean] Is MPD
stopped?
# File lib/ruby-mpd/plugins/information.rb, line 108 def stopped? status[:state] == :stop end
Gets the volume level. @return [Integer]
# File lib/ruby-mpd/plugins/information.rb, line 114 def volume status[:volume] end