From 4f6dcb0b5b8f1737096e4f625286dbc69d6b8253 Mon Sep 17 00:00:00 2001 From: llama <100429699+iamllama@users.noreply.github.com> Date: Sun, 13 Apr 2025 12:43:25 +0800 Subject: [PATCH] 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 --- qt/aqt/sound.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 0b3673c10..48a1852d6 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -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()