Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/ruby-mpd/plugins/controls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions lib/ruby-mpd/plugins/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down