+ fun playing: Bool do return state == "play"
+ fun stopped: Bool do return state == "stop"
+
+ var elapsed: nullable Int
+ var time_at: nullable Int
+ var time_total: nullable Int
+ fun time_ratio: nullable Float do
+ if time_at == null or time_total == null then return null
+ return time_at.to_f / time_total.to_f
+ end
+
+ redef fun to_s do
+ var vol = "unknown"
+ if volume != null then vol = volume.to_s
+
+ var time_at = time_at
+ var time_total = time_total
+ var elapsed = elapsed
+ if time_at != null and time_total != null and elapsed != null then
+ return "volume: {vol}\nstate: {state}\nelapsed: {elapsed}\ntime_[at|total]: {time_at}:{time_total}\ntime_ratio: {time_ratio.as(not null)}"
+ else
+ return "volume: {vol}\nstate: {state}"
+ end
+ end