Fix timer finished sound not looping
Check if player is actually playing before calling stop(for_replacement=True) in MpvMediaPlayer.play(). When the player was already idle, stop(for_replacement=True) would set _suppress_end_event=True with no end-file event to consume it. The next track's end-file callback would then be incorrectly suppressed, breaking the timer loop. - Import PlayerState to check player state - Only call stop(for_replacement=True) when player is not IDLE
This commit is contained in:
1 parent
cf5494642e
commit
3834f51179
1 file changed
+5
-4
@@ -3,6 +3,7 @@ import logging
|
||||
from typing import Union, List, Callable, Optional
|
||||
|
||||
from .player.libmpv import LibMpvPlayer
|
||||
from .player.state import PlayerState
|
||||
|
||||
|
||||
class MpvMediaPlayer:
|
||||
@@ -39,12 +40,12 @@ class MpvMediaPlayer:
|
||||
self._log.debug("Received URL list, using first entry")
|
||||
url = url[0]
|
||||
|
||||
# Track is changing
|
||||
# Track is changing - only stop for replacement if actually playing
|
||||
if self._done_callback is not None:
|
||||
if self._player.state() != PlayerState.IDLE:
|
||||
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
|
||||
|
||||
@@ -87,7 +88,7 @@ class MpvMediaPlayer:
|
||||
Set playback volume.
|
||||
|
||||
Args:
|
||||
volume: Volume in percent (0.0–100.0).
|
||||
volume: Volume in percent (0.0-100.0).
|
||||
"""
|
||||
self._log.debug("set_volume(volume=%.2f)", volume)
|
||||
self._player.set_volume(volume)
|
||||
@@ -97,7 +98,7 @@ class MpvMediaPlayer:
|
||||
Temporarily reduce volume.
|
||||
|
||||
Args:
|
||||
factor: Volume multiplier (0.0–1.0).
|
||||
factor: Volume multiplier (0.0-1.0).
|
||||
"""
|
||||
self._log.debug("duck(factor=%.2f)", factor)
|
||||
self._player.duck(factor)
|
||||
|
||||
Reference in new issue
Block a user