From 5731cb6b3442b383fff13b83c587b8390c352788 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 12 Oct 2014 20:54:57 -0700 Subject: [PATCH] GUAC-882: Wrap calls to new Audio() within try/catch. --- .../src/main/webapp/modules/AudioChannel.js | 90 ++++++++++--------- guacamole/src/main/webapp/scripts/guac-ui.js | 13 ++- 2 files changed, 60 insertions(+), 43 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/AudioChannel.js b/guacamole-common-js/src/main/webapp/modules/AudioChannel.js index 10e56956e..3eb1dca86 100644 --- a/guacamole-common-js/src/main/webapp/modules/AudioChannel.js +++ b/guacamole-common-js/src/main/webapp/modules/AudioChannel.js @@ -121,7 +121,7 @@ Guacamole.AudioChannel.Packet = function(mimetype, data) { * @param {Number} when The time this packet should be played, in * milliseconds. */ - this.play = undefined; // Defined conditionally depending on support + this.play = function(when) { /* NOP */ }; // Defined conditionally depending on support // If audio API available, use it. if (Guacamole.AudioChannel.context) { @@ -181,57 +181,63 @@ Guacamole.AudioChannel.Packet = function(mimetype, data) { var play_on_load = false; // Create audio element to house and play the data - var audio = new Audio(); + var audio = null; + try { audio = new Audio(); } + catch (e) {} - // Read data and start decoding - var reader = new FileReader(); - reader.onload = function() { + if (audio) { - var binary = ""; - var bytes = new Uint8Array(reader.result); + // Read data and start decoding + var reader = new FileReader(); + reader.onload = function() { - // Produce binary string from bytes in buffer - for (var i=0; i