diff --git a/components/PronunciationSpeaker.vue b/components/PronunciationSpeaker.vue index ca8ca3e2d..4a4380b3c 100644 --- a/components/PronunciationSpeaker.vue +++ b/components/PronunciationSpeaker.vue @@ -64,7 +64,8 @@ export default { }, methods: { pronounce() { - if (this.sound) { + if (this.sound && this.sound.src.endsWith(this.pronunciationLink) && !this.sound.error) { + // reuse the sound object if it has the same source and has been loaded without an error this.sound.pause(); this.sound.currentTime = 0; this.sound.play(); @@ -74,7 +75,7 @@ export default { this.sound = new Audio(this.pronunciationLink); - this.sound.addEventListener('loadeddata', () => this.sound.play()); + this.sound.addEventListener('canplay', () => this.sound.play()); this.sound.addEventListener('play', () => this.state = STATE_PLAYING); this.sound.addEventListener('ended', () => this.state = STATE_IDLE); this.sound.addEventListener('error', () => this.state = STATE_IDLE);