diff --git a/src/components/engine-connector/engine-connector.js b/src/components/engine-connector/engine-connector.js index 37aba9875..e4045a4c5 100644 --- a/src/components/engine-connector/engine-connector.js +++ b/src/components/engine-connector/engine-connector.js @@ -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, () => { @@ -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); @@ -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); }); diff --git a/src/reducers/engine.js b/src/reducers/engine.js index 559c5dd30..e0b39cd26 100644 --- a/src/reducers/engine.js +++ b/src/reducers/engine.js @@ -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`, @@ -51,6 +52,7 @@ export const initialState = { isPaused: false, isSeeking: false, isEnded: false, + isPlaybackStarted: false, isPlaybackEnded: false, isChangingSource: false, prePlayback: true, @@ -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, @@ -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}),