mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -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
|
interrupt_current_audio = True
|
||||||
# caller key for the current playback (optional)
|
# caller key for the current playback (optional)
|
||||||
current_caller = None
|
current_caller = None
|
||||||
|
# whether the last call to play_file_with_caller interrupted another
|
||||||
|
current_caller_interrupted = False
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._enqueued: list[AVTag] = []
|
self._enqueued: list[AVTag] = []
|
||||||
|
@ -178,6 +180,8 @@ class AVPlayer:
|
||||||
self.play_tags([SoundOrVideoTag(filename=filename)])
|
self.play_tags([SoundOrVideoTag(filename=filename)])
|
||||||
|
|
||||||
def play_file_with_caller(self, filename: str, caller) -> None:
|
def play_file_with_caller(self, filename: str, caller) -> None:
|
||||||
|
if self.current_caller:
|
||||||
|
self.current_caller_interrupted = True
|
||||||
self.current_caller = caller
|
self.current_caller = caller
|
||||||
self.play_file(filename)
|
self.play_file(filename)
|
||||||
|
|
||||||
|
@ -209,7 +213,9 @@ class AVPlayer:
|
||||||
return self._enqueued.pop(0)
|
return self._enqueued.pop(0)
|
||||||
|
|
||||||
def _on_play_finished(self) -> None:
|
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)
|
gui_hooks.av_player_did_end_playing(self.current_player)
|
||||||
self.current_player = None
|
self.current_player = None
|
||||||
self._play_next_if_idle()
|
self._play_next_if_idle()
|
||||||
|
|
Loading…
Reference in a new issue