diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-17 18:00:28 -0400 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-18 14:23:34 -0400 | 
| commit | 320852f2d01d72c1039d098033081e8266d02be7 (patch) | |
| tree | 5367909b77bac9fbdd1e7d8760d02d782c081ea4 /ext | |
| parent | fcbfde506abf6ca3474d2dfdf4f337b86b0bb579 (diff) | |
Fix overlapping audio.play calls due to await
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/mixed/js/display.js | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index b4a93d99..c2284ffe 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -791,10 +791,7 @@ class Display {              const expression = expressionIndex === -1 ? definition : definition.expressions[expressionIndex]; -            if (this.audioPlaying !== null) { -                this.audioPlaying.pause(); -                this.audioPlaying = null; -            } +            this._stopPlayingAudio();              let audio, info;              try { @@ -820,6 +817,8 @@ class Display {                  button.title = `${titleDefault}\n${info}`;              } +            this._stopPlayingAudio(); +              this.audioPlaying = audio;              audio.currentTime = 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) {          const optionsAnki = this.options.anki;          const fields = (mode === 'kanji' ? optionsAnki.kanji : optionsAnki.terms).fields; |