Skip to content

Commit

Permalink
fix(FEC-8775): preplayback is not updated if play is requested before…
Browse files Browse the repository at this point in the history
… media is loaded (#318)


if play is called on API of player before loadMedia ends then in player we cache the play and when engine loads we start playing.
In UI we set the prePlayback state on the source selected and it might come after the play and case the prePlayback state to be invalid.
  • Loading branch information
OrenMe committed Dec 19, 2018
1 parent 6e59163 commit a7d2bb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/engine-connector/engine-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class EngineConnector extends BaseComponent {
this.eventManager.listen(this.player, this.player.Event.PLAYER_RESET, () => {
this.props.updateCurrentTime(0);
this.props.updateIsIdle(true);
this.props.updateIsPlaybackStarted(false);
});

this.eventManager.listen(this.player, this.player.Event.SOURCE_SELECTED, () => {
Expand All @@ -53,7 +54,7 @@ class EngineConnector extends BaseComponent {
});

this.eventManager.listen(this.player, this.player.Event.CHANGE_SOURCE_STARTED, () => {
this.props.updatePrePlayback(!this.player.config.playback.autoplay);
this.props.updatePrePlayback(!this.player.config.playback.autoplay && !this.props.engine.isPlaybackStarted);
this.props.updateIsChangingSource(true);
this.props.updateFallbackToMutedAutoPlay(false);
this.props.updateAdBreak(false);
Expand Down Expand Up @@ -112,6 +113,7 @@ class EngineConnector extends BaseComponent {

this.eventManager.listen(this.player, this.player.Event.PLAYBACK_START, () => {
this.props.updatePrePlayback(false);
this.props.updateIsPlaybackStarted(true);
this.props.updateLoadingSpinnerState(true);
});

Expand Down
9 changes: 9 additions & 0 deletions src/reducers/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const types = {
UPDATE_LAST_SEEK_POINT: `${component}/UPDATE_LAST_SEEK_POINT`,
UPDATE_IS_CHANGING_SOURCE: `${component}/UPDATE_IS_CHANGING_SOURCE`,
UPDATE_IS_ENDED: `${component}/UPDATE_IS_ENDED`,
UPDATE_IS_PLAYBACK_STARTED: `${component}/UPDATE_IS_PLAYBACK_STARTED`,
UPDATE_IS_PLAYBACK_ENDED: `${component}/UPDATE_IS_PLAYBACK_ENDED`,
UPDATE_CURRENT_TIME: `${component}/UPDATE_CURRENT_TIME`,
UPDATE_DURATION: `${component}/UPDATE_DURATION`,
Expand Down Expand Up @@ -51,6 +52,7 @@ export const initialState = {
isPaused: false,
isSeeking: false,
isEnded: false,
isPlaybackStarted: false,
isPlaybackEnded: false,
isChangingSource: false,
prePlayback: true,
Expand Down Expand Up @@ -147,6 +149,12 @@ export default (state: Object = initialState, action: Object) => {
isEnded: action.isEnded
};

case types.UPDATE_IS_PLAYBACK_STARTED:
return {
...state,
isPlaybackStarted: action.isPlaybackStarted
};

case types.UPDATE_IS_PLAYBACK_ENDED:
return {
...state,
Expand Down Expand Up @@ -347,6 +355,7 @@ export const actions = {
updateIsSeeking: (isSeeking: boolean) => ({type: types.UPDATE_IS_SEEKING, isSeeking}),
updateLastSeekPoint: (lastSeekPoint: number) => ({type: types.UPDATE_LAST_SEEK_POINT, lastSeekPoint}),
updateIsEnded: (isEnded: boolean) => ({type: types.UPDATE_IS_ENDED, isEnded}),
updateIsPlaybackStarted: (isPlaybackStarted: boolean) => ({type: types.UPDATE_IS_PLAYBACK_STARTED, isPlaybackStarted}),
updateIsPlaybackEnded: (isPlaybackEnded: boolean) => ({type: types.UPDATE_IS_PLAYBACK_ENDED, isPlaybackEnded}),
updateCurrentTime: (currentTime: number) => ({type: types.UPDATE_CURRENT_TIME, currentTime}),
updateDuration: (duration: number) => ({type: types.UPDATE_DURATION, duration}),
Expand Down

0 comments on commit a7d2bb8

Please sign in to comment.