Module: MPD::Plugins::Controls

Included in:
MPD
Defined in:
lib/ruby-mpd/plugins/controls.rb

Overview

Commands for controlling playback. Changes have been made to #seek, command maps to seekcur from MPD and the original seek command is #seekpos here.

Instance Method Summary collapse

Instance Method Details

#nextBoolean

Plays the next song in the playlist.

Returns:

  • (Boolean)

    returns true if successful.



9
10
11
# File 'lib/ruby-mpd/plugins/controls.rb', line 9

def next
  send_command :next
end

#pause=(toggle) ⇒ Boolean

Note:

The use of pause without an argument is deprecated in MPD.

Resume/pause playback.

Returns:

  • (Boolean)

    returns true if successful.



16
17
18
# File 'lib/ruby-mpd/plugins/controls.rb', line 16

def pause=(toggle)
  send_command :pause, toggle
end

#play(pos = nil) ⇒ Boolean

Begin playing the playist.

Parameters:

  • pos (Integer) (defaults to: nil)

    Position in the playlist to start playing.

Returns:

  • (Boolean)

    returns true if successful.



23
24
25
# File 'lib/ruby-mpd/plugins/controls.rb', line 23

def play(pos = nil)
  send_command :play, pos
end

#playid(songid = nil) ⇒ Boolean

Begin playing the playlist.

Parameters:

  • songid (Integer) (defaults to: nil)

    ID of the song where to start playing.

Returns:

  • (Boolean)

    returns true if successful.



30
31
32
# File 'lib/ruby-mpd/plugins/controls.rb', line 30

def playid(songid = nil)
  send_command :playid, songid
end

#previousBoolean

Plays the previous song in the playlist.

Returns:

  • (Boolean)

    returns true if successful.



36
37
38
# File 'lib/ruby-mpd/plugins/controls.rb', line 36

def previous
  send_command :previous
end

#seek(time) ⇒ Object

Seeks to the position in seconds within the current song. If prefixed by ‘+’ or ‘-’, then the time is relative to the current playing position.

Returns true if successful,

Parameters:

  • time (Integer, String)

    Position within the current song.

Since:

  • MPD 0.17



47
48
49
# File 'lib/ruby-mpd/plugins/controls.rb', line 47

def seek(time)
  send_command :seekcur, time
end

#seekid(songid, time) ⇒ Boolean

Seeks to the position time (in seconds) of the song with the id of songid.

Returns:

  • (Boolean)

    returns true if successful.



61
62
63
# File 'lib/ruby-mpd/plugins/controls.rb', line 61

def seekid(songid, time)
  send_command :seekid, songid, time
end

#seekpos(pos, time) ⇒ Boolean

Seeks to the position time (in seconds) of the song at pos in the playlist.

Returns:

  • (Boolean)

    returns true if successful.



54
55
56
# File 'lib/ruby-mpd/plugins/controls.rb', line 54

def seekpos(pos, time)
  send_command :seek, pos, time
end

#stopBoolean

Stop playing.

Returns:

  • (Boolean)

    returns true if successful.



67
68
69
# File 'lib/ruby-mpd/plugins/controls.rb', line 67

def stop
  send_command :stop
end