Class: AirPlayer::Controller
- Inherits:
-
Object
- Object
- AirPlayer::Controller
- Defined in:
- lib/airplayer/controller.rb
Instance Method Summary collapse
-
#initialize(options = { device: nil }) ⇒ Controller
constructor
A new instance of Controller.
- #pause ⇒ Object
- #play(media) ⇒ Object
Constructor Details
#initialize(options = { device: nil }) ⇒ Controller
Returns a new instance of Controller.
5 6 7 8 9 |
# File 'lib/airplayer/controller.rb', line 5 def initialize( = { device: nil }) @device = Device.get([:device]) @player = nil @progressbar = nil end |
Instance Method Details
#pause ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/airplayer/controller.rb', line 25 def pause if @player @player.stop end if @progressbar @progressbar.title = 'Complete' @progressbar.finish end end |
#play(media) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/airplayer/controller.rb', line 11 def play(media) puts " Source: #{media.path}" puts " Title: #{media.title}" puts " Device: #{@device.name} (Resolution: #{@device.info.resolution})" @progressbar = ProgressBar.create(format: ' %a |%b%i| %p%% %t') @player = @device.play(media.path) @player.progress -> playback { @progressbar.title = 'Streaming' @progressbar.progress = playback.percent if playback.percent } @player.wait end |