Skip to content

Commit

Permalink
feat: Use VHS playback on any non-Safari browser (#843)
Browse files Browse the repository at this point in the history
Do a check for videojs.browser.IS_ANY_SAFARI and use that for overrideNative so that we use VHS playback on any non-safari browser.

Co-authored-by: ipadilla4 <[email protected]>
Co-authored-by: Garrett Singer <[email protected]>
  • Loading branch information
3 people authored Jun 10, 2020
1 parent 38f5860 commit 225d127
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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

0 comments on commit 225d127

Please sign in to comment.