class Anyplayer::Player
Default Player
class that is inherited by all players.
All players should override these methods:
launched? (return bool) next prev play pause playpause track (return string) artist (return string) album (return string) voldown volup volume (return int) playing? (return bool) paused? (return bool)
Constants
- DEFAULT_VOTES_TO_SKIP
Public Class Methods
new()
click to toggle source
# File lib/anyplayer/player.rb, line 21 def initialize @votes = 0 end
Public Instance Methods
launched?()
click to toggle source
Return true if the player is currently launched
# File lib/anyplayer/player.rb, line 26 def launched? false end
name()
click to toggle source
Player
name defaults to the classe's, feel free to override it Example:
player.name # => iTunes
# File lib/anyplayer/player.rb, line 33 def name self.class.to_s.gsub(/^.*::/, "") end
next()
click to toggle source
Tell the player to go the the next song This resets the votes, so be sure to call super in children
# File lib/anyplayer/player.rb, line 63 def next reset_votes end
paused?()
click to toggle source
Default paused is not playing
# File lib/anyplayer/player.rb, line 38 def paused? !playing? end
platforms()
click to toggle source
Operating systems where this player should work
# File lib/anyplayer/player.rb, line 74 def platforms [:mac, :windows, :linux, :unix] end
playpause()
click to toggle source
Tells the player to toggle the pause state
# File lib/anyplayer/player.rb, line 43 def playpause paused? ? play : pause end
prev()
click to toggle source
Tell the player to go to the previous song This resets the votes, so be sur eto call super in children
# File lib/anyplayer/player.rb, line 69 def prev reset_votes end
vote(votes_to_skip = DEFAULT_VOTES_TO_SKIP)
click to toggle source
Vote to skip this song
# File lib/anyplayer/player.rb, line 48 def vote(votes_to_skip = DEFAULT_VOTES_TO_SKIP) @votes += 1 if @votes >= votes_to_skip self.next reset_votes end end
votes()
click to toggle source
Returns the number of votes to skip this song
# File lib/anyplayer/player.rb, line 57 def votes @votes end
Private Instance Methods
reset_votes()
click to toggle source
# File lib/anyplayer/player.rb, line 80 def reset_votes @votes = 0 end