alexanderwallin / react-player-controls

⏯ Dumb and (re)useful React components for media players.
http://alexanderwallin.github.io/react-player-controls/
ISC License
191 stars 35 forks source link

ProgressBar componentWillUnmount fires onSeekEnd #44

Closed enderortak closed 6 years ago

enderortak commented 6 years ago

ProgressBar componentWillUnmount fires onSeekEnd and this is giving me trouble on the below scenario:

Before starting seek, I pause the playback and restart it if it was playing before the seek.

handleSeekStart = () => this.pausePlayback();
handleSeekEnd = () => { if (this.state.isPlaying) this.startPlayback(this.state.currentPoint); }

To handle unmounting of the component at the middle of a playback, I call my exit handler below:

handleExit =() => {
    this.setState({ isPlaying: false });
    this.stopPlayback();
  }

This works like that:

Is there a way to detect if onSeekEnd is fired by componentWillUnmount? Or any other suggestions are welcomed.

alexanderwallin commented 6 years ago

Hi @enderortak!

<ProgressBar /> should call onSeekEnd() with a value of null if it was triggered from componentWillUnmount(). Have a look and see if that helps.

alexanderwallin commented 6 years ago

This should probably only be fired if the user is currently dragging the slider value.

enderortak commented 6 years ago

@alexanderwallin thank you, checking the value will definitely help!