[go: nahoru, domu]

Skip to content

Commit

Permalink
Check if <audio>.play() returns a promise
Browse files Browse the repository at this point in the history
It doesn't always. IE and Edge crashed when trying to play the bell due
to this. Fixes novnc#929.
  • Loading branch information
samhed committed Oct 17, 2017
1 parent abfe5b7 commit a342ed7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1724,6 +1726,7 @@ var UI = {
Log.Error("Unable to play bell: " + e);
}
});
}
}
},

Expand Down

0 comments on commit a342ed7

Please sign in to comment.