Detect when media position is stale in vlc_telnet (#48434)

PR extracted from #44776.
This commit is contained in:
David McClosky 2021-03-28 12:19:05 -04:00 committed by GitHub
parent 4487565232
commit 48c0cfb25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,7 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
)
import homeassistant.helpers.config_validation as cv
import homeassistant.util.dt as dt_util
_LOGGER = logging.getLogger(__name__)
@ -141,7 +142,12 @@ class VlcDevice(MediaPlayerEntity):
if self._state != STATE_IDLE:
self._media_duration = self._vlc.get_length()
self._media_position = self._vlc.get_time()
vlc_position = self._vlc.get_time()
# Check if current position is stale.
if vlc_position != self._media_position:
self._media_position_updated_at = dt_util.utcnow()
self._media_position = vlc_position
info = self._vlc.info()
_LOGGER.debug("Info: %s", info)