mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-882: Wrap calls to new Audio() within try/catch.
This commit is contained in:
@@ -121,7 +121,7 @@ Guacamole.AudioChannel.Packet = function(mimetype, data) {
|
|||||||
* @param {Number} when The time this packet should be played, in
|
* @param {Number} when The time this packet should be played, in
|
||||||
* milliseconds.
|
* 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 audio API available, use it.
|
||||||
if (Guacamole.AudioChannel.context) {
|
if (Guacamole.AudioChannel.context) {
|
||||||
@@ -181,7 +181,11 @@ Guacamole.AudioChannel.Packet = function(mimetype, data) {
|
|||||||
var play_on_load = false;
|
var play_on_load = false;
|
||||||
|
|
||||||
// Create audio element to house and play the data
|
// 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
|
// Read data and start decoding
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
@@ -235,4 +239,6 @@ Guacamole.AudioChannel.Packet = function(mimetype, data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -187,7 +187,18 @@ GuacUI.Audio = new (function() {
|
|||||||
// Build array of supported audio formats
|
// Build array of supported audio formats
|
||||||
codecs.forEach(function(mimetype) {
|
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);
|
var support_level = audio.canPlayType(mimetype);
|
||||||
|
|
||||||
// Trim semicolon and trailer
|
// Trim semicolon and trailer
|
||||||
|
Reference in New Issue
Block a user