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 = 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 .title = 'Complete' .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.create(format: ' %a |%b%i| %p%% %t') @player = @device.play(media.path) @player.progress -> playback { .title = 'Streaming' .progress = playback.percent if playback.percent } @player.wait end |