Skip to content

Commit

Permalink
fix(FEC-7535): setting autoplay causes player spinner before loading …
Browse files Browse the repository at this point in the history
…media (#185)

If were setting up the player and calling later in the code to loadMedia (or configure with sources) spinner will be showing endlessly (not the best user experience).
So we need to raise up the spinner only when source selected and autoplay is on and exclude the case of an ad break.
  • Loading branch information
Dan Ziv committed Feb 27, 2018
1 parent 1d23872 commit e80334a
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions src/components/loading/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const mapStateToProps = state => ({
* @extends {BaseComponent}
*/
class Loading extends BaseComponent {
autoplay: boolean;

/**
* Creates an instance of Loading.
* @param {Object} obj obj
Expand All @@ -38,21 +36,6 @@ class Loading extends BaseComponent {
this.setState({afterPlayingEvent: false});
}

/**
* before component mount, update the autoplay and mobileAutoplay values from player config
*
* @returns {void}
* @memberof Loading
*/
componentWillMount() {
try {
this.autoplay = this.player.config.playback.autoplay;
} catch (e) { // eslint-disable-line no-unused-vars
this.autoplay = false;
}

}

/**
* after component mounted, set event listener to player state change and update the state of loading spinner accordingly.
* initially, if not mobile and autoplay is on, show the loading spinner without dependency on the player state.
Expand All @@ -62,10 +45,6 @@ class Loading extends BaseComponent {
* @memberof Loading
*/
componentDidMount() {
if (this.autoplay) {
this.props.updateLoadingSpinnerState(true);
}

this.player.addEventListener(this.player.Event.PLAYER_STATE_CHANGED, e => {
const StateType = this.player.State;
if (!this.state.afterPlayingEvent) {
Expand All @@ -80,6 +59,12 @@ class Loading extends BaseComponent {
}
});

this.player.addEventListener(this.player.Event.SOURCE_SELECTED, () => {
if (this.player.config.autoplay) {
this.props.updateLoadingSpinnerState(true);
}
});

this.player.addEventListener(this.player.Event.AD_BREAK_START, () => {
this.props.updateLoadingSpinnerState(true);
});
Expand Down

0 comments on commit e80334a

Please sign in to comment.