Fix mpv pause state when loading new media
Fixes #107 This fixes an issue where loading a new media URL while the player was paused would keep playback paused, causing Music Assistant to show the player as playing while no audio was audible. The mpv pause state is now always set explicitly when starting playback, ensuring deterministic behavior
This commit is contained in:
1 parent
7a92d69864
commit
d42abaa2c9
6 files changed
+205
-68
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import time
|
||||
import mpv
|
||||
|
||||
"""
|
||||
mpv_smoke_test.py - test playback of media
|
||||
"""
|
||||
|
||||
def handle_event(event):
|
||||
print(f"EVENT: {event['event_id']}")
|
||||
|
||||
|
||||
player = mpv.MPV(
|
||||
audio_display=False,
|
||||
log_handler=print,
|
||||
loglevel="info",
|
||||
)
|
||||
|
||||
player.event_callback = handle_event
|
||||
|
||||
print("Loading media...")
|
||||
player.play("https://icecast.radiofrance.fr/fip-midfi.mp3")
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
print("Pausing...")
|
||||
player.pause = True
|
||||
time.sleep(2)
|
||||
|
||||
print("Resuming...")
|
||||
player.pause = False
|
||||
time.sleep(5)
|
||||
|
||||
print("Stopping...")
|
||||
player.stop()
|
||||
|
||||
time.sleep(2)
|
||||
print("Done.")
|
||||
@@ -0,0 +1,23 @@
|
||||
import time
|
||||
import logging
|
||||
|
||||
from linux_voice_assistant.player.libmpv import LibMpvPlayer
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
player = LibMpvPlayer()
|
||||
|
||||
player.play("https://icecast.radiofrance.fr/fip-midfi.mp3")
|
||||
time.sleep(5)
|
||||
|
||||
player.pause()
|
||||
time.sleep(2)
|
||||
|
||||
player.resume()
|
||||
time.sleep(5)
|
||||
|
||||
player.stop()
|
||||
time.sleep(2)
|
||||
|
||||
print("Final state:", player.state())
|
||||
Reference in new issue
Block a user