Fix autoplay not being stopped on editor close if it interrupted another (#3915)

* fix autoplay not stopped on editor close if it interrupted another

* Update qt/aqt/sound.py
This commit is contained in:
llama 2025-04-13 12:43:25 +08:00 committed by GitHub
parent 1fa99c97e4
commit 4f6dcb0b5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -142,6 +142,8 @@ class AVPlayer:
interrupt_current_audio = True
# caller key for the current playback (optional)
current_caller = None
# whether the last call to play_file_with_caller interrupted another
current_caller_interrupted = False
def __init__(self) -> None:
self._enqueued: list[AVTag] = []
@ -178,6 +180,8 @@ class AVPlayer:
self.play_tags([SoundOrVideoTag(filename=filename)])
def play_file_with_caller(self, filename: str, caller) -> None:
if self.current_caller:
self.current_caller_interrupted = True
self.current_caller = caller
self.play_file(filename)
@ -209,7 +213,9 @@ class AVPlayer:
return self._enqueued.pop(0)
def _on_play_finished(self) -> None:
self.current_caller = None
if not self.current_caller_interrupted:
self.current_caller = None
self.current_caller_interrupted = False
gui_hooks.av_player_did_end_playing(self.current_player)
self.current_player = None
self._play_next_if_idle()