Merge remote-tracking branch 'origin/main'

This commit is contained in:
Andrea Vos 2024-01-29 18:57:21 +01:00
commit 88661eb5ed

View File

@ -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);