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 all 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
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,22 +288,24 @@ is true, if the platform supports Media Source Extensions
videojs-http-streaming will take over HLS playback to provide a more
consistent experience.

__NOTE__: If you use this option, you must also set
`html5.nativeAudioTracks` and `html5.nativeVideoTracks` to
`false`. videojs-http-streaming relies on audio and video tracks to play
streams with alternate audio and requires additional capabilities only
supported by non-native tracks in video.js.

```javascript
// via the constructor
var player = videojs('playerId', {
html5: {
nativeAudioTracks: false,
nativeVideoTracks: false,
hls: {
overrideNative: true
}
}
});

// via the source
var player = videojs('playerId');

player.src({
src: 'https://example.com/index.m3u8',
type: 'application/x-mpegURL',
overrideNative: true
});
```

##### blacklistDuration
Expand Down
2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
(function(window, videojs) {
var player = window.player = videojs('videojs-http-streaming-player', {
html5: {
nativeAudioTracks: !!videojs.browser.IS_SAFARI,
nativeVideoTracks: !!videojs.browser.IS_SAFARI,
hls: {
overrideNative: !videojs.browser.IS_SAFARI
}
Expand Down
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