Class: Airplay::Player::PlaybackInfo

Inherits:
Struct
  • Object
show all
Defined in:
lib/airplay/player/playback_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#infoObject

Returns the value of attribute info

Returns:

  • (Object)

    the current value of info



3
4
5
# File 'lib/airplay/player/playback_info.rb', line 3

def info
  @info
end

Instance Method Details

#durationObject



8
9
10
# File 'lib/airplay/player/playback_info.rb', line 8

def duration
  info["duration"]
end

#has_duration?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


25
26
27
# File 'lib/airplay/player/playback_info.rb', line 25

def likely_to_keep_up?
  info["playbackLikelyToKeepUp"]
end

#paused?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/airplay/player/playback_info.rb', line 45

def paused?
  !playing?
end

#percentObject



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

Returns:

  • (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

Returns:

  • (Boolean)


41
42
43
# File 'lib/airplay/player/playback_info.rb', line 41

def playing?
  info.has_key?("rate") && info.fetch("rate", false) && !info["rate"].zero?
end

#positionObject



16
17
18
# File 'lib/airplay/player/playback_info.rb', line 16

def position
  info["position"]
end

#ready_to_play?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/airplay/player/playback_info.rb', line 33

def ready_to_play?
  info["readyToPlay"]
end

#stall_countObject



29
30
31
# File 'lib/airplay/player/playback_info.rb', line 29

def stall_count
  info["stallCount"]
end

#stopped?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/airplay/player/playback_info.rb', line 37

def stopped?
  info.empty?
end

#uuidObject



4
5
6
# File 'lib/airplay/player/playback_info.rb', line 4

def uuid
  info["uuid"]
end