Safely handle volume values that are out of range (#617)

This commit is contained in:
toasted-nutbread 2020-06-21 15:51:36 -04:00 committed by GitHub
parent 713bf29377
commit 9e28db6ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -807,9 +807,10 @@ class Display {
this._stopPlayingAudio();
const volume = Math.max(0.0, Math.min(1.0, this.options.audio.volume / 100.0));
this.audioPlaying = audio;
audio.currentTime = 0;
audio.volume = this.options.audio.volume / 100.0;
audio.volume = Number.isFinite(volume) ? volume : 1.0;
const playPromise = audio.play();
if (typeof playPromise !== 'undefined') {
try {