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

fix: Default overrideNative to check if browser is any Safari #843

Merged
merged 3 commits into from
Jun 10, 2020
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
2 changes: 1 addition & 1 deletion src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,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);
Expand Down
28 changes: 27 additions & 1 deletion test/videojs-http-streaming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand Down