Class: Airplay::Player::PlaybackInfo
- Inherits:
-
Struct
- Object
- Struct
- Airplay::Player::PlaybackInfo
- Defined in:
- lib/airplay/player/playback_info.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
Returns the value of attribute info.
Instance Method Summary collapse
- #duration ⇒ Object
- #has_duration? ⇒ Boolean
- #likely_to_keep_up? ⇒ Boolean
- #paused? ⇒ Boolean
- #percent ⇒ Object
- #played? ⇒ Boolean
- #playing? ⇒ Boolean
- #position ⇒ Object
- #ready_to_play? ⇒ Boolean
- #stall_count ⇒ Object
- #stopped? ⇒ Boolean
- #uuid ⇒ Object
Instance Attribute Details
#info ⇒ Object
Returns the value of attribute info
3 4 5 |
# File 'lib/airplay/player/playback_info.rb', line 3 def info @info end |
Instance Method Details
#duration ⇒ Object
8 9 10 |
# File 'lib/airplay/player/playback_info.rb', line 8 def duration info["duration"] end |
#has_duration? ⇒ Boolean
12 13 14 |
# File 'lib/airplay/player/playback_info.rb', line 12 def has_duration? !duration.to_f.zero? end |
#likely_to_keep_up? ⇒ Boolean
25 26 27 |
# File 'lib/airplay/player/playback_info.rb', line 25 def likely_to_keep_up? info["playbackLikelyToKeepUp"] end |
#paused? ⇒ Boolean
45 46 47 |
# File 'lib/airplay/player/playback_info.rb', line 45 def paused? ! end |
#percent ⇒ Object
20 21 22 23 |
# File 'lib/airplay/player/playback_info.rb', line 20 def percent return unless position && has_duration? (position * 100 / duration).floor end |
#played? ⇒ Boolean
49 50 51 52 |
# File 'lib/airplay/player/playback_info.rb', line 49 def played? # This is weird. I know. Bear with me. info.keys.size == 2 end |
#playing? ⇒ Boolean
41 42 43 |
# File 'lib/airplay/player/playback_info.rb', line 41 def info.has_key?("rate") && info.fetch("rate", false) && !info["rate"].zero? end |
#position ⇒ Object
16 17 18 |
# File 'lib/airplay/player/playback_info.rb', line 16 def position info["position"] end |
#ready_to_play? ⇒ Boolean
33 34 35 |
# File 'lib/airplay/player/playback_info.rb', line 33 def ready_to_play? info["readyToPlay"] end |
#stall_count ⇒ Object
29 30 31 |
# File 'lib/airplay/player/playback_info.rb', line 29 def stall_count info["stallCount"] end |
#stopped? ⇒ Boolean
37 38 39 |
# File 'lib/airplay/player/playback_info.rb', line 37 def stopped? info.empty? end |
#uuid ⇒ Object
4 5 6 |
# File 'lib/airplay/player/playback_info.rb', line 4 def uuid info["uuid"] end |