mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Keep track of last play status update time in Apple TV (#142838)
This commit is contained in:
parent
34767d4058
commit
88eef379b2
@ -120,6 +120,7 @@ class AppleTvMediaPlayer(
|
|||||||
"""Initialize the Apple TV media player."""
|
"""Initialize the Apple TV media player."""
|
||||||
super().__init__(name, identifier, manager)
|
super().__init__(name, identifier, manager)
|
||||||
self._playing: Playing | None = None
|
self._playing: Playing | None = None
|
||||||
|
self._playing_last_updated: datetime | None = None
|
||||||
self._app_list: dict[str, str] = {}
|
self._app_list: dict[str, str] = {}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -209,6 +210,7 @@ class AppleTvMediaPlayer(
|
|||||||
This is a callback function from pyatv.interface.PushListener.
|
This is a callback function from pyatv.interface.PushListener.
|
||||||
"""
|
"""
|
||||||
self._playing = playstatus
|
self._playing = playstatus
|
||||||
|
self._playing_last_updated = dt_util.utcnow()
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -316,7 +318,7 @@ class AppleTvMediaPlayer(
|
|||||||
def media_position_updated_at(self) -> datetime | None:
|
def media_position_updated_at(self) -> datetime | None:
|
||||||
"""Last valid time of media position."""
|
"""Last valid time of media position."""
|
||||||
if self.state in {MediaPlayerState.PLAYING, MediaPlayerState.PAUSED}:
|
if self.state in {MediaPlayerState.PLAYING, MediaPlayerState.PAUSED}:
|
||||||
return dt_util.utcnow()
|
return self._playing_last_updated
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def async_play_media(
|
async def async_play_media(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user