Class: XiamiRadio::Player
- Inherits:
-
Object
- Object
- XiamiRadio::Player
- Defined in:
- lib/xiami_radio/player.rb
Overview
There is a player as you saw
Instance Attribute Summary collapse
-
#next_track ⇒ Object
readonly
Returns the value of attribute next_track.
-
#radio ⇒ Object
readonly
Returns the value of attribute radio.
-
#track ⇒ Object
readonly
Returns the value of attribute track.
Instance Method Summary collapse
- #forward ⇒ Object
-
#initialize(radio:, _playlist: nil) ⇒ Player
constructor
A new instance of Player.
- #next ⇒ Object
- #play ⇒ Object
- #rewind ⇒ Object
- #toggle ⇒ Object
Constructor Details
#initialize(radio:, _playlist: nil) ⇒ Player
Returns a new instance of Player.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/xiami_radio/player.rb', line 9 def initialize(radio:, _playlist: nil) @radio = radio @player = Audite.new @view = View::Player.new @player.events.on :position_change, &method(:position_change) @player.events.on :complete, &method(:complete) @view.listen_on self trap(:SIGUSR1) { self.next } end |
Instance Attribute Details
#next_track ⇒ Object (readonly)
Returns the value of attribute next_track.
7 8 9 |
# File 'lib/xiami_radio/player.rb', line 7 def next_track @next_track end |
#radio ⇒ Object (readonly)
Returns the value of attribute radio.
7 8 9 |
# File 'lib/xiami_radio/player.rb', line 7 def radio @radio end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
7 8 9 |
# File 'lib/xiami_radio/player.rb', line 7 def track @track end |
Instance Method Details
#forward ⇒ Object
44 45 46 |
# File 'lib/xiami_radio/player.rb', line 44 def forward @player.forward end |
#next ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/xiami_radio/player.rb', line 29 def next @track.downloader.stop if preload? @track, @next_track = @next_track, nil else @track = @radio.next_track @player.queue @track.file_path end @player.request_next_song end |
#play ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/xiami_radio/player.rb', line 21 def play @track = @radio.next_track @player.queue @track.file_path @player.set_current_song @player.start_stream @player.thread.join end |
#rewind ⇒ Object
40 41 42 |
# File 'lib/xiami_radio/player.rb', line 40 def rewind @player.rewind end |
#toggle ⇒ Object
48 49 50 |
# File 'lib/xiami_radio/player.rb', line 48 def toggle @player.toggle end |