Class: Anyplayer::Player
- Inherits:
-
Object
- Object
- Anyplayer::Player
- Defined in:
- lib/anyplayer/player.rb
Overview
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)
Direct Known Subclasses
Amarok, ItunesMac, ItunesWindows, Mpd, Noplayer, RdioMac, Rhythmbox, SpotifyMac, Xmms2
Constant Summary collapse
- DEFAULT_VOTES_TO_SKIP =
5
Instance Method Summary collapse
-
#initialize ⇒ Player
constructor
A new instance of Player.
-
#launched? ⇒ Boolean
Return true if the player is currently launched.
-
#name ⇒ Object
Player name defaults to the classe’s, feel free to override it Example: player.name # => iTunes.
-
#next ⇒ Object
Tell the player to go the the next song This resets the votes, so be sure to call super in children.
-
#paused? ⇒ Boolean
Default paused is not playing.
-
#platforms ⇒ Object
Operating systems where this player should work.
-
#playpause ⇒ Object
Tells the player to toggle the pause state.
-
#prev ⇒ Object
Tell the player to go to the previous song This resets the votes, so be sur eto call super in children.
-
#vote(votes_to_skip = DEFAULT_VOTES_TO_SKIP) ⇒ Object
Vote to skip this song.
-
#votes ⇒ Object
Returns the number of votes to skip this song.
Constructor Details
#initialize ⇒ Player
Returns a new instance of Player.
21 22 23 |
# File 'lib/anyplayer/player.rb', line 21 def initialize @votes = 0 end |
Instance Method Details
#launched? ⇒ Boolean
Return true if the player is currently launched
26 27 28 |
# File 'lib/anyplayer/player.rb', line 26 def launched? false end |
#name ⇒ Object
Player name defaults to the classe’s, feel free to override it Example:
player.name # => iTunes
33 34 35 |
# File 'lib/anyplayer/player.rb', line 33 def name self.class.to_s.gsub(/^.*::/, "") end |
#next ⇒ Object
Tell the player to go the the next song This resets the votes, so be sure to call super in children
63 64 65 |
# File 'lib/anyplayer/player.rb', line 63 def next reset_votes end |
#paused? ⇒ Boolean
Default paused is not playing
38 39 40 |
# File 'lib/anyplayer/player.rb', line 38 def paused? ! end |
#platforms ⇒ Object
Operating systems where this player should work
74 75 76 |
# File 'lib/anyplayer/player.rb', line 74 def platforms [:mac, :windows, :linux, :unix] end |
#playpause ⇒ Object
Tells the player to toggle the pause state
43 44 45 |
# File 'lib/anyplayer/player.rb', line 43 def playpause paused? ? play : pause end |
#prev ⇒ Object
Tell the player to go to the previous song This resets the votes, so be sur eto call super in children
69 70 71 |
# File 'lib/anyplayer/player.rb', line 69 def prev reset_votes end |
#vote(votes_to_skip = DEFAULT_VOTES_TO_SKIP) ⇒ Object
Vote to skip this song
48 49 50 51 52 53 54 |
# 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 ⇒ Object
Returns the number of votes to skip this song
57 58 59 |
# File 'lib/anyplayer/player.rb', line 57 def votes @votes end |