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)


126
127
128
# File 'lib/ruby-mpd/plugins/information.rb', line 126

def consume?
  return status[:consume]
end

#crossfadeInteger

Returns Crossfade in seconds.

Returns:

  • (Integer)

    Crossfade in seconds.



116
117
118
# File 'lib/ruby-mpd/plugins/information.rb', line 116

def crossfade
  return status[:xfade]
end

#current_songMPD::Song

Get the currently playing song

Returns:



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.

Parameters:

  • masks (Symbol)

    A list of subsystems we want to be notified on.

Since:

  • MPD 0.14



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?

Returns:

  • (Boolean)


94
95
96
# File 'lib/ruby-mpd/plugins/information.rb', line 94

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

#playing?Boolean

Is MPD playing?

Returns:

  • (Boolean)


100
101
102
# File 'lib/ruby-mpd/plugins/information.rb', line 100

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

#playlist_versionInteger

Returns Current playlist version number.

Returns:

  • (Integer)

    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,

Returns:

  • (Boolean)


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,

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


131
132
133
# File 'lib/ruby-mpd/plugins/information.rb', line 131

def single?
  return 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.



86
87
88
# File 'lib/ruby-mpd/plugins/information.rb', line 86

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.



72
73
74
# File 'lib/ruby-mpd/plugins/information.rb', line 72

def status
  send_command :status
end

#stopped?Boolean

Returns Is MPD stopped?.

Returns:

  • (Boolean)

    Is MPD stopped?



105
106
107
# File 'lib/ruby-mpd/plugins/information.rb', line 105

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

#volumeInteger

Gets the volume level.

Returns:

  • (Integer)


111
112
113
# File 'lib/ruby-mpd/plugins/information.rb', line 111

def volume
  return status[:volume]
end