Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Utilize option to override native on tech #76

Merged
merged 6 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,15 @@ class HlsHandler extends Component {
this.ignoreNextSeekingEvent_ = false;
this.setOptions_();

// overriding native HLS only works if audio tracks have been emulated
// error early if we're misconfigured:
if (this.options_.overrideNative &&
(tech.featuresNativeVideoTracks || tech.featuresNativeAudioTracks)) {
tech.overrideNativeAudioTracks &&
tech.overrideNativeVideoTracks) {
tech.overrideNativeAudioTracks(true);
tech.overrideNativeVideoTracks(true);
} else if (this.options_.overrideNative &&
(tech.featuresNativeVideoTracks || tech.featuresNativeAudioTracks)) {
// overriding native HLS only works if audio tracks have been emulated
// error early if we're misconfigured
throw new Error('Overriding native HLS requires emulated tracks. ' +
'See https://git.io/vMpjB');
}
Expand Down
27 changes: 13 additions & 14 deletions test/videojs-http-streaming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1988,13 +1988,13 @@ QUnit.test('loads if native HLS is available and override is set locally', funct
player = createPlayer({html5: {hls: {overrideNative: true}}});
this.clock.tick(1);
player.tech_.featuresNativeVideoTracks = true;
assert.throws(function() {
player.src({
src: 'http://example.com/manifest/master.m3u8',
type: 'application/x-mpegURL'
});
this.clock.tick(1);
}, 'errors if native tracks are enabled');
player.src({
src: 'http://example.com/manifest/master.m3u8',
type: 'application/x-mpegURL'
});
this.clock.tick(1);

assert.ok(player.tech_.hls, 'did load hls tech');
player.dispose();

player = createPlayer({html5: {hls: {overrideNative: true}}});
Expand All @@ -2018,13 +2018,12 @@ QUnit.test('loads if native HLS is available and override is set globally', func
Hls.supportsNativeHls = true;
player = createPlayer();
player.tech_.featuresNativeVideoTracks = true;
assert.throws(function() {
player.src({
src: 'http://example.com/manifest/master.m3u8',
type: 'application/x-mpegURL'
});
this.clock.tick(1);
}, 'errors if native tracks are enabled');
player.src({
src: 'http://example.com/manifest/master.m3u8',
type: 'application/x-mpegURL'
});
this.clock.tick(1);
assert.ok(player.tech_.hls, 'did load hls tech');
player.dispose();

player = createPlayer();
Expand Down
4 changes: 0 additions & 4 deletions utils/stats/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ <h3>Timed Metadata</h3>
}

videojs.options.hls.overrideNative = overrideNative === 'on';
if (videojs.options.hls.overrideNative) {
videojs.options.html5.nativeAudioTracks = false;
videojs.options.html5.nativeVideoTracks = false;
}

var type = document.getElementById('url-content-type').value;
// use the form data to add a src to the player
Expand Down