Module: MPD::Plugins::Controls
- Included in:
- MPD
- Defined in:
- lib/ruby-mpd/plugins/controls.rb
Overview
Commands for controlling playback.
Instance Method Summary collapse
-
#next ⇒ Boolean
Plays the next song in the playlist.
-
#pause=(toggle) ⇒ Boolean
Resume/pause playback.
-
#play(pos = nil) ⇒ Boolean
Begin/resume playing the queue.
-
#previous ⇒ Boolean
Plays the previous song in the playlist.
-
#seek(time, options = {}) ⇒ Boolean
Seeks to the position in seconds within the current song.
-
#stop ⇒ Boolean
Stop playing.
Instance Method Details
#next ⇒ Boolean
Plays the next song in the playlist.
7 8 9 |
# File 'lib/ruby-mpd/plugins/controls.rb', line 7 def next send_command :next end |
#pause=(toggle) ⇒ Boolean
Resume/pause playback.
13 14 15 |
# File 'lib/ruby-mpd/plugins/controls.rb', line 13 def pause=(toggle) send_command :pause, toggle end |
#play(pos = nil) ⇒ Boolean
Begin/resume playing the queue.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby-mpd/plugins/controls.rb', line 21 def play(pos = nil) if pos.is_a?(Hash) if pos[:id] send_command :playid, priority, pos[:id] else raise ArgumentError, 'Only :id key is allowed!' end else send_command :play, pos end end |
#previous ⇒ Boolean
Plays the previous song in the playlist.
35 36 37 |
# File 'lib/ruby-mpd/plugins/controls.rb', line 35 def previous send_command :previous end |
#seek(time, options = {}) ⇒ Boolean
Seeks to the position in seconds within the current song. If prefixed by ‘+’ or ‘-’, then the time is relative to the current playing position.
47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby-mpd/plugins/controls.rb', line 47 def seek(time, = {}) if [:id] send_command :seekid, [:id], time elsif [:pos] send_command :seek, [:pos], time else send_command :seekcur, time end end |
#stop ⇒ Boolean
Stop playing.
59 60 61 |
# File 'lib/ruby-mpd/plugins/controls.rb', line 59 def stop send_command :stop end |