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
38 lines
551 B
Python
38 lines
551 B
Python
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.")
|