Fix mpv pause state when loading new media
Prevent IDLE state and done callback on track replacement mpv emits an end-file event when playback is stopped. During track replacement this caused the media player to transition to IDLE and notify Home Assistant even though a new track was already playing. Introduce a suppression flag to distinguish track replacement from natural playback end and avoid incorrect state transitions.
This commit is contained in:
1 parent
c5032a0605
commit
b2d4ec1413
2 files changed
+28
-8
No files matched your search
@@ -39,6 +39,15 @@ class MpvMediaPlayer:
|
||||
self._log.debug("Received URL list, using first entry")
|
||||
url = url[0]
|
||||
|
||||
# Track is changing
|
||||
if self._done_callback is not None:
|
||||
self._log.debug(
|
||||
"Stopping active playback before starting new media"
|
||||
)
|
||||
# Not self.stop() → this would call done_callback
|
||||
self._player.stop(for_replacement=True)
|
||||
self._done_callback = None
|
||||
|
||||
self._log.info("Playing media: %s", url)
|
||||
self._log.debug(
|
||||
"play(url=%s, stop_first=%s, done_callback=%s)",
|
||||
|
||||
Reference in new issue
Block a user