diff options
author | Sam Potts <sam@potts.es> | 2018-12-08 16:50:44 +1100 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-12-08 16:50:44 +1100 |
commit | a0303969c2c6875790d600444f357b12bdb09b50 (patch) | |
tree | 5673b2d1dc62ebfa0313ff637225850fc4f1fb55 /src | |
parent | 2c8a337f265f3f84133bc674f3836802588c0c13 (diff) | |
download | plyr-a0303969c2c6875790d600444f357b12bdb09b50.tar.lz plyr-a0303969c2c6875790d600444f357b12bdb09b50.tar.xz plyr-a0303969c2c6875790d600444f357b12bdb09b50.zip |
Fix for error when mime type not specified (fixes #1274)
Diffstat (limited to 'src')
-rw-r--r-- | src/js/html5.js | 13 | ||||
-rw-r--r-- | src/js/support.js | 12 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/js/html5.js b/src/js/html5.js index 0876211a..3266a58e 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -5,6 +5,7 @@ import support from './support'; import { removeElement } from './utils/elements'; import { triggerEvent } from './utils/events'; +import is from './utils/is'; const html5 = { getSources() { @@ -14,8 +15,16 @@ const html5 = { const sources = Array.from(this.media.querySelectorAll('source')); - // Filter out unsupported sources - return sources.filter(source => support.mime.call(this, source.getAttribute('type'))); + // Filter out unsupported sources (if type is specified) + return sources.filter(source => { + const type = source.getAttribute('type'); + + if (is.empty(type)) { + return true; + } + + return support.mime.call(this, type); + }); }, // Get quality levels diff --git a/src/js/support.js b/src/js/support.js index 9257df13..81965867 100644 --- a/src/js/support.js +++ b/src/js/support.js @@ -68,9 +68,13 @@ 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('/'); - let type = inputType; + 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) { @@ -79,7 +83,7 @@ const support = { // Add codec if required if (Object.keys(defaultCodecs).includes(type)) { - type += `; codecs="${defaultCodecs[inputType]}"`; + type += `; codecs="${defaultCodecs[input]}"`; } try { |