Catch errors for when we can't play bell

Many browsers, for example Chrome on Android will not allow audio to
play unless it's initiated from a user action. It is not reasonable to
display an error for this. Fixes issue #821.
This commit is contained in:
Samuel Mannehed 2017-05-12 12:52:05 +02:00
parent 53f41f9692
commit d4fc89d8b9
1 changed files with 10 additions and 1 deletions

View File

@ -1681,7 +1681,16 @@ const UI = {
bell: function(rfb) {
if (WebUtil.getConfigVar('bell', 'on') === 'on') {
document.getElementById('noVNC_bell').play();
document.getElementById('noVNC_bell').play()
.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
// initiated from a user action.
} else {
Log.Error("Unable to play bell: " + e);
}
});
}
},