Merge pull request #285 from glyptodon/video-error

GUAC-1375: Use Guacamole.VideoPlayer.getSupportedTypes() instead of canPlayType()
This commit is contained in:
James Muehlner
2015-11-02 14:00:23 -08:00

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2014 Glyptodon LLC * Copyright (C) 2015 Glyptodon LLC
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -30,47 +30,10 @@ angular.module('client').factory('guacVideo', [function guacVideo() {
*/ */
return new (function() { return new (function() {
var codecs = [
'video/ogg; codecs="theora, vorbis"',
'video/mp4; codecs="avc1.4D401E, mp4a.40.5"',
'video/webm; codecs="vp8.0, vorbis"'
];
var probably_supported = [];
var maybe_supported = [];
/** /**
* Array of all supported video mimetypes, ordered by liklihood of * Array of all supported video mimetypes.
* working.
*/ */
this.supported = []; this.supported = Guacamole.VideoPlayer.getSupportedTypes();
// Build array of supported audio formats
codecs.forEach(function(mimetype) {
var video = document.createElement("video");
var support_level = video.canPlayType(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);
});
// Add probably supported types first
Array.prototype.push.apply(
this.supported, probably_supported);
// Prioritize "maybe" supported types second
Array.prototype.push.apply(
this.supported, maybe_supported);
})(); })();