mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUAC-1044: Fix audio error when using IE over RDP - it's blocking testing (regression of GUAC-882).
This commit is contained in:
@@ -30,6 +30,11 @@ angular.module('client').factory('guacAudio', [function guacAudio() {
|
|||||||
*/
|
*/
|
||||||
return new (function() {
|
return new (function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of codecs to test.
|
||||||
|
*
|
||||||
|
* @type String[]
|
||||||
|
*/
|
||||||
var codecs = [
|
var codecs = [
|
||||||
'audio/ogg; codecs="vorbis"',
|
'audio/ogg; codecs="vorbis"',
|
||||||
'audio/mp4; codecs="mp4a.40.5"',
|
'audio/mp4; codecs="mp4a.40.5"',
|
||||||
@@ -38,41 +43,70 @@ angular.module('client').factory('guacAudio', [function guacAudio() {
|
|||||||
'audio/wav; codecs=1'
|
'audio/wav; codecs=1'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of all codecs that are reported as "probably" supported.
|
||||||
|
*
|
||||||
|
* @type String[]
|
||||||
|
*/
|
||||||
var probably_supported = [];
|
var probably_supported = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of all codecs that are reported as "maybe" supported.
|
||||||
|
*
|
||||||
|
* @type String[]
|
||||||
|
*/
|
||||||
var maybe_supported = [];
|
var maybe_supported = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal audio element for the sake of testing codec support. If
|
||||||
|
* audio is explicitly not supported by the browser, this will instead
|
||||||
|
* be null.
|
||||||
|
*
|
||||||
|
* @type Audio
|
||||||
|
*/
|
||||||
|
var audio = null;
|
||||||
|
|
||||||
|
// Attempt to create audio element
|
||||||
|
try {
|
||||||
|
audio = new Audio();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// If creation fails, allow audio to remain null
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of all supported audio mimetypes, ordered by liklihood of
|
* Array of all supported audio mimetypes, ordered by liklihood of
|
||||||
* working.
|
* working.
|
||||||
*/
|
*/
|
||||||
this.supported = [];
|
this.supported = [];
|
||||||
|
|
||||||
// Build array of supported audio formats
|
// Build array of supported audio formats (if audio supported at all)
|
||||||
codecs.forEach(function(mimetype) {
|
if (audio) {
|
||||||
|
codecs.forEach(function(mimetype) {
|
||||||
|
|
||||||
var audio = new Audio();
|
var support_level = audio.canPlayType(mimetype);
|
||||||
var support_level = audio.canPlayType(mimetype);
|
|
||||||
|
|
||||||
// Trim semicolon and trailer
|
// Trim semicolon and trailer
|
||||||
var semicolon = mimetype.indexOf(";");
|
var semicolon = mimetype.indexOf(";");
|
||||||
if (semicolon != -1)
|
if (semicolon !== -1)
|
||||||
mimetype = mimetype.substring(0, semicolon);
|
mimetype = mimetype.substring(0, semicolon);
|
||||||
|
|
||||||
// Partition by probably/maybe
|
// Partition by probably/maybe
|
||||||
if (support_level == "probably")
|
if (support_level === "probably")
|
||||||
probably_supported.push(mimetype);
|
probably_supported.push(mimetype);
|
||||||
else if (support_level == "maybe")
|
else if (support_level === "maybe")
|
||||||
maybe_supported.push(mimetype);
|
maybe_supported.push(mimetype);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add probably supported types first
|
// Add probably supported types first
|
||||||
Array.prototype.push.apply(
|
Array.prototype.push.apply(
|
||||||
this.supported, probably_supported);
|
this.supported, probably_supported);
|
||||||
|
|
||||||
// Prioritize "maybe" supported types second
|
// Prioritize "maybe" supported types second
|
||||||
Array.prototype.push.apply(
|
Array.prototype.push.apply(
|
||||||
this.supported, maybe_supported);
|
this.supported, maybe_supported);
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user