Fix overlapping audio.play calls due to await
This commit is contained in:
parent
fcbfde506a
commit
320852f2d0
@ -791,10 +791,7 @@ class Display {
|
|||||||
|
|
||||||
const expression = expressionIndex === -1 ? definition : definition.expressions[expressionIndex];
|
const expression = expressionIndex === -1 ? definition : definition.expressions[expressionIndex];
|
||||||
|
|
||||||
if (this.audioPlaying !== null) {
|
this._stopPlayingAudio();
|
||||||
this.audioPlaying.pause();
|
|
||||||
this.audioPlaying = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let audio, info;
|
let audio, info;
|
||||||
try {
|
try {
|
||||||
@ -820,6 +817,8 @@ class Display {
|
|||||||
button.title = `${titleDefault}\n${info}`;
|
button.title = `${titleDefault}\n${info}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._stopPlayingAudio();
|
||||||
|
|
||||||
this.audioPlaying = audio;
|
this.audioPlaying = audio;
|
||||||
audio.currentTime = 0;
|
audio.currentTime = 0;
|
||||||
audio.volume = this.options.audio.volume / 100.0;
|
audio.volume = this.options.audio.volume / 100.0;
|
||||||
@ -838,6 +837,13 @@ class Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_stopPlayingAudio() {
|
||||||
|
if (this.audioPlaying !== null) {
|
||||||
|
this.audioPlaying.pause();
|
||||||
|
this.audioPlaying = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
noteUsesScreenshot(mode) {
|
noteUsesScreenshot(mode) {
|
||||||
const optionsAnki = this.options.anki;
|
const optionsAnki = this.options.anki;
|
||||||
const fields = (mode === 'kanji' ? optionsAnki.kanji : optionsAnki.terms).fields;
|
const fields = (mode === 'kanji' ? optionsAnki.kanji : optionsAnki.terms).fields;
|
||||||
|
Loading…
Reference in New Issue
Block a user