diff options
Diffstat (limited to 'libmpd/playbackcontrol.rb')
-rw-r--r-- | libmpd/playbackcontrol.rb | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/libmpd/playbackcontrol.rb b/libmpd/playbackcontrol.rb index 1e7a9c4..5707703 100644 --- a/libmpd/playbackcontrol.rb +++ b/libmpd/playbackcontrol.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # #-- -# Copyright 2009 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> +# Copyright 2009-2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> # Distributed under the terms of the GNU General Public License v3. # See http://www.gnu.org/licenses/gpl.txt for the full license text. #++ @@ -13,69 +13,66 @@ module MPDPlaybackControl # Plays the next song in the playlist. def next - return send_request('next') + send_request('next') end # Sets pause state. # # Accepts an argument of +true+ to enable or +false+ to disable. # If no argument is given, defaults to +true+. - def pause(state=true) - return send_request('pause %s' % state.to_i) + def pause(state = true) + send_request('pause %s' % state.to_i) end # Returns +true+ if paused. # Otherwise, returns +false+. def paused? - return true if status[:state] == 'pause' - return false + status[:state] == 'pause' end # Begins playing the playlist. If an argument is given, begins at the # specified song position. - def play(songpos=nil) + def play(songpos = nil) command = 'play' command << ' %s' % songpos if songpos - return send_request(command) + send_request(command) end # Begins playing the playlist. If an argument is given, begins at the # specified song id. - def playid(songid=nil) + def playid(songid = nil) command = 'playid' command << ' %s' % songid if songid - return send_request(command) + send_request(command) end # Returns +true+ if playing. # Otherwise, returns +false+. def playing? - return true if status[:state] == 'play' - return false + status[:state] == 'play' end # Plays the previous song in the playlist. def previous - return send_request('previous') + send_request('previous') end # Seeks to the given position of the current song. # Accepts an argument of seconds. def seek(time) - return send_request('seek %s %s' % [status[:song], time]) + send_request('seek %s %s' % [status[:song], time]) end # Stops playing. def stop - return send_request('stop') + send_request('stop') end # Returns +true+ if stopped. # Otherwise, returns +false+. def stopped? - return true if status[:state] == 'stop' - return false + status[:state] == 'stop' end end |