Fix media_position for cast component (#8452)

* Make it available during state paused.

* Don't adjust for media_position_updated_at. I.e. do as vlc, sonos etc
  so that returned position is the position at the time of
  media_position_updated_at, not now.
pull/8468/head
dersger 2017-07-14 05:00:23 +02:00 committed by Paulus Schoutsen
parent 21e82bd037
commit bd1e533409
1 changed files with 3 additions and 8 deletions

View File

@ -234,18 +234,13 @@ class CastDevice(MediaPlayerDevice):
@property
def media_position(self):
"""Position of current playing media in seconds."""
if self.media_status is None or self.media_status_received is None or \
if self.media_status is None or \
not (self.media_status.player_is_playing or
self.media_status.player_is_paused or
self.media_status.player_is_idle):
return None
position = self.media_status.current_time
if self.media_status.player_is_playing:
position += (dt_util.utcnow() -
self.media_status_received).total_seconds()
return position
return self.media_status.current_time
@property
def media_position_updated_at(self):