GUAC-882: Wrap calls to new Audio() within try/catch.

This commit is contained in:
Michael Jumper
2014-10-12 20:54:57 -07:00
parent 2202ede609
commit 5731cb6b34
2 changed files with 60 additions and 43 deletions

View File

@@ -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,7 +181,11 @@ 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) {}
if (audio) {
// Read data and start decoding
var reader = new FileReader();
@@ -235,4 +239,6 @@ Guacamole.AudioChannel.Packet = function(mimetype, data) {
}
}
};

View File

@@ -187,7 +187,18 @@ GuacUI.Audio = new (function() {
// Build array of supported audio formats
codecs.forEach(function(mimetype) {
var audio = new Audio();
// Attempt to get audio element for mimetype testing
var audio = null;
try {
audio = new Audio();
}
catch (e) {
// Skip testing if audio is not available
return;
}
var support_level = audio.canPlayType(mimetype);
// Trim semicolon and trailer