diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 2904879c..1839b436 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -879,7 +879,7 @@ const HlsSourceHandler = { return tech.hls; }, canPlayType(type, options = {}) { - const { hls: { overrideNative } } = videojs.mergeOptions(videojs.options, options); + const { hls: { overrideNative = !videojs.browser.IS_ANY_SAFARI } } = videojs.mergeOptions(videojs.options, options); const supportedType = simpleTypeFromSourceType(type); const canUseMsePlayback = supportedType && (!Hls.supportsTypeNatively(supportedType) || overrideNative); diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index 2e406b03..da3ef118 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -2839,10 +2839,12 @@ QUnit.test( } ); -QUnit.test('has no effect if native HLS is available', function(assert) { +QUnit.test('has no effect if native HLS is available and browser is Safari', function(assert) { const Html5 = videojs.getTech('Html5'); const oldHtml5CanPlaySource = Html5.canPlaySource; + const origIsAnySafari = videojs.browser.IS_ANY_SAFARI; + videojs.browser.IS_ANY_SAFARI = true; Html5.canPlaySource = () => true; Hls.supportsNativeHls = true; const player = createPlayer(); @@ -2857,6 +2859,30 @@ QUnit.test('has no effect if native HLS is available', function(assert) { assert.ok(!player.tech_.hls, 'did not load hls tech'); player.dispose(); Html5.canPlaySource = oldHtml5CanPlaySource; + videojs.browser.IS_ANY_SAFARI = origIsAnySafari; +}); + +QUnit.test('loads if native HLS is available but browser is not Safari', function(assert) { + const Html5 = videojs.getTech('Html5'); + const oldHtml5CanPlaySource = Html5.canPlaySource; + const origIsAnySafari = videojs.browser.IS_ANY_SAFARI; + + videojs.browser.IS_ANY_SAFARI = false; + Html5.canPlaySource = () => true; + Hls.supportsNativeHls = true; + const player = createPlayer(); + + player.src({ + src: 'http://example.com/manifest/master.m3u8', + type: 'application/x-mpegURL' + }); + + this.clock.tick(1); + + assert.ok(player.tech_.hls, 'loaded hls tech'); + player.dispose(); + Html5.canPlaySource = oldHtml5CanPlaySource; + videojs.browser.IS_ANY_SAFARI = origIsAnySafari; }); QUnit.test(