From d4fc89d8b9f584fc251aa15c6c72d0b9a3e02dee Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Fri, 12 May 2017 12:52:05 +0200 Subject: [PATCH] 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. --- app/ui.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ui.js b/app/ui.js index 4c4bedf7..194fefdf 100644 --- a/app/ui.js +++ b/app/ui.js @@ -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); + } + }); } },