Skip to content

Commit

Permalink
fix(FEC-8474): playback starts muted on change media - iOS (#151)
Browse files Browse the repository at this point in the history
### Description of the Changes
**Issue**: The auto play testing video tag is created before any user gesture, hence in change media it returns that auto play is non valid although the main video tag can auto play.
**Solution**: Listen to the first `UI_CLICKED` event (once `SOURCE_SELECTED` event) and call to `setCapabilities` with `autoPlay:true`
  • Loading branch information
yairans authored Aug 19, 2018
1 parent cdefcc0 commit c5f332f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import {setDefaultAnalyticsPlugin} from 'player-defaults';
import {Env, TextStyle, Utils} from 'playkit-js';
import {Env, TextStyle, Utils, setCapabilities, EngineType} from 'playkit-js';
import {ValidationErrorType} from './validation-error';
import StorageManager from '../storage/storage-manager';
import type {LogLevelObject} from './logger';
Expand Down Expand Up @@ -104,6 +104,25 @@ function setStorageTextStyle(player: Player): void {
}
}

/**
* Call to setCapabilities on the first UI_CLICKED event
* @param {Player} player - The Kaltura player.
* @returns {void}
*/
function attachToFirstClick(player: Player): void {
if (isIos()) {
const onUIClicked = () => {
player.removeEventListener(player.Event.UI.UI_CLICKED, onUIClicked);
setCapabilities(EngineType.HTML5, {autoplay: true});
};
const onSourceSelected = () => {
player.removeEventListener(player.Event.SOURCE_SELECTED, onSourceSelected);
player.addEventListener(player.Event.UI.UI_CLICKED, onUIClicked);
};
player.addEventListener(player.Event.SOURCE_SELECTED, onSourceSelected);
}
}
/**
* check the player debug mode according to config or URL query string params
* @returns {boolean} - if to set debug mode or not
Expand Down Expand Up @@ -335,6 +354,7 @@ export {
setStorageConfig,
applyStorageSupport,
setStorageTextStyle,
attachToFirstClick,
validateConfig,
setLogLevel,
createKalturaPlayerContainer,
Expand Down
4 changes: 3 additions & 1 deletion src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
setStorageConfig,
setStorageTextStyle,
supportLegacyOptions,
validateConfig
validateConfig,
attachToFirstClick
} from './common/utils/setup-helpers';

/**
Expand All @@ -28,6 +29,7 @@ function setup(options: PartialKalturaPlayerOptionsObject | LegacyPartialKaltura
const kalturaPlayer = new KalturaPlayer(defaultOptions);
setStorageTextStyle(kalturaPlayer);
applyStorageSupport(kalturaPlayer);
attachToFirstClick(kalturaPlayer);
return kalturaPlayer;
}

Expand Down

0 comments on commit c5f332f

Please sign in to comment.