Module: MPD::Plugins::Queue
- Included in:
- MPD
- Defined in:
- lib/ruby-mpd/plugins/queue.rb
Overview
These commands manipulate the current playlist, what’s playing now. For a distinction between this and other playlists, this is called queue. Changes: playlistinfo -> queue, plchanges -> queue_changes,
playlistid -> song_with_id.
Instance Method Summary collapse
-
#add(path) ⇒ Boolean
Add the file path to the queue.
-
#addid(path, pos = nil) ⇒ Object
Adds a song to the queue (non-recursive) and returns the song id.
-
#clear ⇒ Boolean
Clears the current queue.
-
#delete(pos) ⇒ Boolean
Deletes the song from the queue.
-
#deleteid(songid) ⇒ Boolean
Delete the song with the
songid
from the queue. -
#move(from, to) ⇒ Boolean
Move the song at
from
toto
in the queue. -
#moveid(songid, to) ⇒ Boolean
Move the song with the
songid
toto
in the queue. -
#queue(limit = nil) ⇒ MPD::Song+
List the current playlist/queue.
-
#queue_changes(version) ⇒ Array<MPD::Song>
List the changes since the specified version in the queue.
-
#save(playlist) ⇒ Boolean
Saves the current playlist/queue to
playlist
.m3u in the playlist directory. -
#shuffle(range) ⇒ Boolean
Shuffles the queue.
-
#song_with_id(songid) ⇒ MPD::Song
Returns the song with the
songid
in the playlist,. -
#swap(posA, posB) ⇒ Boolean
Swaps the song at position
posA
with the song as positionposB
in the queue. -
#swapid(songidA, songidB) ⇒ Boolean
Swaps the positions of the song with the id
songidA
with the song with the idsongidB
in the queue.
Instance Method Details
#add(path) ⇒ Boolean
Add the file path to the queue. If path is a directory, it will be added recursively.
23 24 25 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 23 def add(path) send_command :add, path end |
#addid(path, pos = nil) ⇒ Object
Adds a song to the queue (non-recursive) and returns the song id. Optionally, one can specify the position on which to add the song (since MPD 0.14).
29 30 31 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 29 def addid(path, pos=nil) send_command :addid, pos end |
#clear ⇒ Boolean
Clears the current queue.
35 36 37 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 35 def clear send_command :clear end |
#delete(pos) ⇒ Boolean
Deletes the song from the queue.
Since MPD 0.15 a range can also be passed. Songs with positions within range will be deleted. if range is passed, songs with positions within range will be deleted.
45 46 47 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 45 def delete(pos) send_command :delete, pos end |
#deleteid(songid) ⇒ Boolean
Delete the song with the songid
from the queue.
51 52 53 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 51 def deleteid(songid) send_command :deleteid, songid end |
#move(from, to) ⇒ Boolean
Move the song at from
to to
in the queue.
-
Since 0.14,
to
can be a negative number, which is the offset of the song from the currently playing (or to-be-played) song. So -1 would mean the song would be moved to be the next song in the queue. Moving a song to -queue.length will move it to the song before the current song on the queue; so this will work for repeating playlists, too. -
Since 0.15,
from
can be a range of songs to move.
63 64 65 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 63 def move(from, to) send_command :move, from, to end |
#moveid(songid, to) ⇒ Boolean
Move the song with the songid
to to
in the queue.
69 70 71 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 69 def moveid(songid, to) send_command :moveid, songid, to end |
#queue(limit = nil) ⇒ MPD::Song+
List the current playlist/queue. An Integer or Range can be used to limit the information returned to a specific subset.
or a single song.
16 17 18 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 16 def queue(limit=nil) build_songs_list send_command(:playlistinfo, limit) end |
#queue_changes(version) ⇒ Array<MPD::Song>
List the changes since the specified version in the queue.
85 86 87 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 85 def queue_changes(version) build_songs_list send_command(:plchanges, version) end |
#save(playlist) ⇒ Boolean
Saves the current playlist/queue to playlist
.m3u in the playlist directory.
119 120 121 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 119 def save(playlist) send_command :save, playlist end |
#shuffle(range) ⇒ Boolean
Shuffles the queue. Optionally, a Range can be used to shuffle a specific subset.
98 99 100 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 98 def shuffle(range) send_command :shuffle, range end |
#song_with_id(songid) ⇒ MPD::Song
Returns the song with the songid
in the playlist,
77 78 79 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 77 def song_with_id(songid) Song.new send_command(:playlistid, songid) end |
#swap(posA, posB) ⇒ Boolean
Swaps the song at position posA
with the song as position posB
in the queue.
105 106 107 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 105 def swap(posA, posB) send_command :swap, posA, posB end |
#swapid(songidA, songidB) ⇒ Boolean
Swaps the positions of the song with the id songidA
with the song with the id songidB
in the queue.
112 113 114 |
# File 'lib/ruby-mpd/plugins/queue.rb', line 112 def swapid(songidA, songidB) send_command :swapid, songidA, songidB end |