module MPD::Plugins::Information

Informational commands regarding MPD’s current status.

Public Instance Methods

clearerror() click to toggle source

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
consume?() click to toggle source

Returns true if consume is enabled.

# File lib/ruby-mpd/plugins/information.rb, line 129
def consume?
  status[:consume]
end
crossfade() click to toggle source

@return [Integer] Crossfade in seconds.

# File lib/ruby-mpd/plugins/information.rb, line 119
def crossfade
  status[:xfade]
end
current_song() click to toggle source

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
paused?() click to toggle source

Is MPD paused? @return [Boolean]

# File lib/ruby-mpd/plugins/information.rb, line 97
def paused?
  status[:state] == :pause
end
playing?() click to toggle source

Is MPD playing? @return [Boolean]

# File lib/ruby-mpd/plugins/information.rb, line 103
def playing?
  status[:state] == :play
end
playlist_version() click to toggle source

@return [Integer] Current playlist version number.

# File lib/ruby-mpd/plugins/information.rb, line 124
def playlist_version
  status[:playlist]
end
random?() click to toggle source

Returns true if random playback is currently enabled,

# File lib/ruby-mpd/plugins/information.rb, line 139
def random?
  status[:random]
end
repeat?() click to toggle source

Returns true if repeat is enabled,

# File lib/ruby-mpd/plugins/information.rb, line 144
def repeat?
  status[:repeat]
end
single?() click to toggle source

Returns true if single is enabled.

# File lib/ruby-mpd/plugins/information.rb, line 134
def single?
  status[:single]
end
stats() click to toggle source

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
status() click to toggle source

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
stopped?() click to toggle source

@return [Boolean] Is MPD stopped?

# File lib/ruby-mpd/plugins/information.rb, line 108
def stopped?
  status[:state] == :stop
end
volume() click to toggle source

Gets the volume level. @return [Integer]

# File lib/ruby-mpd/plugins/information.rb, line 114
def volume
  status[:volume]
end