Fix for error when mime type not specified (fixes #1274)
This commit is contained in:
parent
2c8a337f26
commit
a0303969c2
@ -5,6 +5,7 @@
|
|||||||
import support from './support';
|
import support from './support';
|
||||||
import { removeElement } from './utils/elements';
|
import { removeElement } from './utils/elements';
|
||||||
import { triggerEvent } from './utils/events';
|
import { triggerEvent } from './utils/events';
|
||||||
|
import is from './utils/is';
|
||||||
|
|
||||||
const html5 = {
|
const html5 = {
|
||||||
getSources() {
|
getSources() {
|
||||||
@ -14,8 +15,16 @@ const html5 = {
|
|||||||
|
|
||||||
const sources = Array.from(this.media.querySelectorAll('source'));
|
const sources = Array.from(this.media.querySelectorAll('source'));
|
||||||
|
|
||||||
// Filter out unsupported sources
|
// Filter out unsupported sources (if type is specified)
|
||||||
return sources.filter(source => support.mime.call(this, source.getAttribute('type')));
|
return sources.filter(source => {
|
||||||
|
const type = source.getAttribute('type');
|
||||||
|
|
||||||
|
if (is.empty(type)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return support.mime.call(this, type);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get quality levels
|
// Get quality levels
|
||||||
|
@ -68,9 +68,13 @@ const support = {
|
|||||||
// Check for mime type support against a player instance
|
// Check for mime type support against a player instance
|
||||||
// Credits: http://diveintohtml5.info/everything.html
|
// Credits: http://diveintohtml5.info/everything.html
|
||||||
// Related: http://www.leanbackplayer.com/test/h5mt.html
|
// Related: http://www.leanbackplayer.com/test/h5mt.html
|
||||||
mime(inputType) {
|
mime(input) {
|
||||||
const [mediaType] = inputType.split('/');
|
if (is.empty(input)) {
|
||||||
let type = inputType;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [mediaType] = input.split('/');
|
||||||
|
let type = input;
|
||||||
|
|
||||||
// Verify we're using HTML5 and there's no media type mismatch
|
// Verify we're using HTML5 and there's no media type mismatch
|
||||||
if (!this.isHTML5 || mediaType !== this.type) {
|
if (!this.isHTML5 || mediaType !== this.type) {
|
||||||
@ -79,7 +83,7 @@ const support = {
|
|||||||
|
|
||||||
// Add codec if required
|
// Add codec if required
|
||||||
if (Object.keys(defaultCodecs).includes(type)) {
|
if (Object.keys(defaultCodecs).includes(type)) {
|
||||||
type += `; codecs="${defaultCodecs[inputType]}"`;
|
type += `; codecs="${defaultCodecs[input]}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user