Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Don't error if MediaSource isn't defined (#876)
Browse files Browse the repository at this point in the history
If a CODECS attribute is present on an m3u8 but MSE isn't present, don't explode. In practice, this means only exclude variants based on codec for MSE mode.
  • Loading branch information
dmlap authored Oct 19, 2016
1 parent eeeb7ec commit 7cd1a66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/master-playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,9 @@ export class MasterPlaylistController extends videojs.EventTarget {
let codecString = variant.attributes.CODECS;

variantCodecs = parseCodecs(codecString);
if (!MediaSource.isTypeSupported('video/mp4; codecs="' + codecString + '"')) {
if (window.MediaSource &&
window.MediaSource.isTypeSupported &&
!window.MediaSource.isTypeSupported('video/mp4; codecs="' + codecString + '"')) {
variant.excludeUntil = Infinity;
}
}
Expand Down
17 changes: 17 additions & 0 deletions test/videojs-contrib-hls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,23 @@ QUnit.module('HLS Integration', {
}
});

QUnit.test('does not error when MediaSource is not defined', function() {
window.MediaSource = null;

let hls = HlsSourceHandler('html5').handleSource({
src: 'manifest/alternateAudio.m3u8',
type: 'application/vnd.apple.mpegurl'
}, this.tech);

hls.mediaSource.trigger('sourceopen');
// master
standardXHRResponse(this.requests.shift());
// media
standardXHRResponse(this.requests.shift());

QUnit.ok(true, 'did not throw an exception');
});

QUnit.test('aborts all in-flight work when disposed', function() {
let hls = HlsSourceHandler('html5').handleSource({
src: 'manifest/master.m3u8',
Expand Down

0 comments on commit 7cd1a66

Please sign in to comment.