Await and handle errors from audio.play()
This commit is contained in:
parent
9fe7b9ad29
commit
fcbfde506a
@ -40,7 +40,7 @@ class TextToSpeechAudio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
play() {
|
async play() {
|
||||||
try {
|
try {
|
||||||
if (this._utterance === null) {
|
if (this._utterance === null) {
|
||||||
this._utterance = new SpeechSynthesisUtterance(this.text || '');
|
this._utterance = new SpeechSynthesisUtterance(this.text || '');
|
||||||
|
@ -823,7 +823,14 @@ class Display {
|
|||||||
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;
|
||||||
audio.play();
|
const playPromise = audio.play();
|
||||||
|
if (typeof playPromise !== 'undefined') {
|
||||||
|
try {
|
||||||
|
await playPromise;
|
||||||
|
} catch (e2) {
|
||||||
|
// NOP
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.onError(e);
|
this.onError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user