ruby-mpd
ruby-mpd copied to clipboard
Insert at position
mpc has a feature to insert a song at a specific position, is this available here as well?
It's not, I was able to hack together a very way similar to how mpc handles it though.
qlen = @mpd.queue.length
@mpd.add uri
newqlen = @mpd.queue.length
@mpd.move "#{qlen}:#{newqlen}", @mpd.status[:nextsong]
Basically you got to add the track/playlist to the queue and then move it to the position after the current song.
Extend the class like this:
class MPD
# Insert a song to the queue after the current track
# @macro returnraise
def insert(path)
qlen = self.queue.length
self.add path
newqlen = self.queue.length
self.move "#{qlen}:#{newqlen}", self.status[:nextsong]
self.next
end
end