diff --git a/README.md b/README.md index 8e0a33df3..32cac480b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.html b/index.html index e8eaed651..8404fcca2 100644 --- a/index.html +++ b/index.html @@ -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 } diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 620305e65..db56111d0 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -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'); } diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index aaf42a74b..7eca3c0f8 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -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}}}); @@ -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(); diff --git a/utils/stats/index.html b/utils/stats/index.html index 9670c3829..7ad332ff8 100644 --- a/utils/stats/index.html +++ b/utils/stats/index.html @@ -227,10 +227,6 @@

Timed Metadata

} 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