mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 04:34:15 -04:00
(fix) reload sound in <PronunciationSpeaker> if an error occured or the input changed
This commit is contained in:
parent
760636ad2f
commit
c0a4c41d4b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user