souporserious / react-media-player

React audio and video player.
https://souporserious.github.io/react-media-player/
ISC License
470 stars 100 forks source link

How to seekTo on componentDidMount #21

Open xpluscal opened 7 years ago

xpluscal commented 7 years ago

Hi,

I'd like to seekTo a certain time when my Media component ist loaded. I do not use a custom player, but this:

export default MediaPlayer = withMediaProps(withMediaPlayer(MediaPlayer));

and inside the MediaPlayer component I use this to seekTo the time set via Redux:

componentDidMount(){
    let that = this;
    if(this.props.startTime && this.props.media){
      that.props.media.seekTo(that.props.startTime);
    }
  }

Any ideas what could be wrong? Thanks

souporserious commented 7 years ago

Sorry, I just saw this issue. Can you provide anymore code? Maybe the whole component so I can get an idea of what's going on? I've been thinking about adding a startTime prop or something similar to define when the video should start playing similar to how Youtube allows you to set a start time.