u-wave/react-youtube

Feature Request: getDuration() and getCurrentTime() support please

cjmling opened this issue · 2 comments

I tried to look into doc if it already support but doesn't seems like.

Will be nice to have this support. Personally I want to able to do stuff when player played till certain times/percent.

I tried setInterval in createPlayer and was able to get the data.

Sample codes can be seen here.
http://www.opimedia.be/DS/webdev/YouTube/

var current = youTubePlayer.getCurrentTime();
var duration = youTubePlayer.getDuration();

You can get a reference to the YouTube Player object using the onReady event handler, by doing something like:

<YouTube
  onReady={(event) => {
    const youTubePlayer = event.target
    // now you can do:
    youTubePlayer.getCurrentTime()
  }}
/>

Ok that should work great :D

but currently , it never called back? #26