ruby-mpd icon indicating copy to clipboard operation
ruby-mpd copied to clipboard

Insert at position

Open xeruf opened this issue 4 years ago • 2 comments

mpc has a feature to insert a song at a specific position, is this available here as well?

xeruf avatar Oct 14 '21 16:10 xeruf

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.

LevitatingBusinessMan avatar Jan 20 '22 01:01 LevitatingBusinessMan

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

LevitatingBusinessMan avatar Jan 20 '22 02:01 LevitatingBusinessMan