Skip to content

Commit

Permalink
fix(FEC-7192): play native HLS on iOS (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenMe authored and Dan Ziv committed Sep 25, 2017
1 parent b78e47a commit 9b27213
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
22 changes: 20 additions & 2 deletions src/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function addKalturaPoster(metadata: Object, width: number, height: number): void
* @returns {void}
*/
function checkNativeHlsSupport(playerConfig: Object): void {
if (Env.browser.name.includes("Safari")) {
if (isSafari() || isIos()) {
let preferNativeHlsValue = Utils.Object.getPropertyPath(playerConfig, 'playback.preferNative.hls');
if (typeof preferNativeHlsValue !== 'boolean') {
Utils.Object.mergeDeep(playerConfig, {
Expand All @@ -113,12 +113,30 @@ function checkNativeHlsSupport(playerConfig: Object): void {
}
}

/**
* Returns true if user agent indicate that browser is Safari
* @returns {boolean} - if browser is Safari
*/
function isSafari(): boolean{
return Env.browser.name.includes("Safari");
}

/**
* Returns true if user agent indicate that browser is Chrome on iOS
* @returns {boolean} - if browser is Chrome on iOS
*/
function isIos(): boolean{
return (Env.os.name === "iOS");
}

export {
extractPlayerConfig,
extractProvidersConfig,
createKalturaPlayerContainer,
addKalturaPoster,
validateTargetId,
validateProvidersConfig,
checkNativeHlsSupport
checkNativeHlsSupport,
isSafari,
isIos
};
11 changes: 6 additions & 5 deletions test/src/utils/setup-helpers.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Env} from 'playkit-js'
import * as TestUtils from 'playkit-js/test/src/utils/test-utils'
import {ValidationErrorType} from '../../../src/utils/validation-error'
import {
Expand All @@ -8,7 +7,9 @@ import {
validateTargetId,
validateProvidersConfig,
addKalturaPoster,
checkNativeHlsSupport
checkNativeHlsSupport,
isSafari,
isIos
} from '../../../src/utils/setup-helpers'

const targetId = 'player-placeholder_setup-helpers.spec';
Expand Down Expand Up @@ -293,7 +294,7 @@ describe('checkNativeHlsSupport', function () {
it('set preferNative to default value if user preference was not set 1', function () {
const playerConfig = {};
checkNativeHlsSupport(playerConfig);
if (Env.browser.name === "Safari") {
if (isSafari() || isIos()) {
playerConfig.playback.preferNative.hls.should.be.true;
} else {
playerConfig.should.deep.equal({});
Expand All @@ -305,7 +306,7 @@ describe('checkNativeHlsSupport', function () {
playback: {}
};
checkNativeHlsSupport(playerConfig);
if (Env.browser.name === "Safari") {
if (isSafari() || isIos()) {
playerConfig.playback.preferNative.hls.should.be.true;
} else {
playerConfig.should.deep.equal({
Expand All @@ -321,7 +322,7 @@ describe('checkNativeHlsSupport', function () {
}
};
checkNativeHlsSupport(playerConfig);
if (Env.browser.name === "Safari") {
if (isSafari() || isIos()) {
playerConfig.playback.preferNative.hls.should.be.true;
} else {
playerConfig.should.deep.equal({
Expand Down

0 comments on commit 9b27213

Please sign in to comment.