Detect audio and prioritize supported audio mimetypes.

This commit is contained in:
Michael Jumper
2012-10-23 19:59:03 -07:00
parent a585e52546
commit 0bb8495426

View File

@@ -490,6 +490,9 @@ GuacamoleUI.supportedAudio = [];
GuacamoleUI.eventTarget.style.top = window.pageYOffset + "px";
});
var probably_supported = [];
var maybe_supported = [];
// Build array of supported audio formats
[
'audio/ogg; codecs="vorbis"',
@@ -500,11 +503,22 @@ GuacamoleUI.supportedAudio = [];
var audio = new Audio();
var support_level = audio.canPlayType(mimetype);
if (support_level != "")
GuacamoleUI.supportedAudio.push(mimetype);
// Trim semicolon and trailer
var semicolon = mimetype.indexOf(";");
if (semicolon != -1)
mimetype = mimetype.substring(0, semicolon);
// Partition by probably/maybe
if (support_level == "probably")
probably_supported.push(mimetype);
else if (support_level == "maybe")
maybe_supported.push(mimetype);
});
Array.prototype.push.apply(GuacamoleUI.supportedAudio, probably_supported);
Array.prototype.push.apply(GuacamoleUI.supportedAudio, maybe_supported);
})();
// Tie UI events / behavior to a specific Guacamole client