Check if <audio>.play() returns a promise
It doesn't always. IE and Edge crashed when trying to play the bell due to this. Fixes #929.
This commit is contained in:
parent
abfe5b7a37
commit
a342ed703f
|
@ -1714,8 +1714,10 @@ var UI = {
|
|||
|
||||
bell: function(rfb) {
|
||||
if (WebUtil.getConfigVar('bell', 'on') === 'on') {
|
||||
document.getElementById('noVNC_bell').play()
|
||||
.catch(function(e) {
|
||||
var promise = document.getElementById('noVNC_bell').play();
|
||||
// The standards disagree on the return value here
|
||||
if (promise) {
|
||||
promise.catch(function(e) {
|
||||
if (e.name === "NotAllowedError") {
|
||||
// Ignore when the browser doesn't let us play audio.
|
||||
// It is common that the browsers require audio to be
|
||||
|
@ -1724,6 +1726,7 @@ var UI = {
|
|||
Log.Error("Unable to play bell: " + e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue