aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/support.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/support.js')
-rw-r--r--src/js/support.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/js/support.js b/src/js/support.js
index 59f27c3b..81965867 100644
--- a/src/js/support.js
+++ b/src/js/support.js
@@ -68,27 +68,27 @@ const support = {
// Check for mime type support against a player instance
// Credits: http://diveintohtml5.info/everything.html
// Related: http://www.leanbackplayer.com/test/h5mt.html
- mime(inputType) {
- const [mediaType] = inputType.split('/');
+ mime(input) {
+ if (is.empty(input)) {
+ return false;
+ }
+
+ const [mediaType] = input.split('/');
+ let type = input;
+
+ // Verify we're using HTML5 and there's no media type mismatch
if (!this.isHTML5 || mediaType !== this.type) {
return false;
}
- let type;
- if (inputType && inputType.includes('codecs=')) {
- // Use input directly
- type = inputType;
- } else if (inputType === 'audio/mpeg') {
- // Skip codec
- type = 'audio/mpeg;';
- } else if (inputType in defaultCodecs) {
- // Use codec
- type = `${inputType}; codecs="${defaultCodecs[inputType]}"`;
+ // Add codec if required
+ if (Object.keys(defaultCodecs).includes(type)) {
+ type += `; codecs="${defaultCodecs[input]}"`;
}
try {
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
- } catch (err) {
+ } catch (e) {
return false;
}
},