diff --git a/lib/ruby-mpd/plugins/controls.rb b/lib/ruby-mpd/plugins/controls.rb index 3b8cc20..074fda2 100644 --- a/lib/ruby-mpd/plugins/controls.rb +++ b/lib/ruby-mpd/plugins/controls.rb @@ -59,6 +59,18 @@ def seek(time, options = {}) def stop send_command :stop end + + # Play if paused, pause if playing + # @macro returnraise + def toggle + case self.status[:state] + when :play + send_command :pause + else + send_command :play + end + end + end end end diff --git a/lib/ruby-mpd/plugins/queue.rb b/lib/ruby-mpd/plugins/queue.rb index 2c34ab4..5b1e519 100644 --- a/lib/ruby-mpd/plugins/queue.rb +++ b/lib/ruby-mpd/plugins/queue.rb @@ -22,6 +22,16 @@ def add(path) send_command :add, path end + # 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 + # 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). # @return [Integer] id of the song that was added.