mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
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:
parent
1fa99c97e4
commit
4f6dcb0b5b
1 changed files with 7 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue