react-youtube icon indicating copy to clipboard operation
react-youtube copied to clipboard

Unstarted (-1) event not firing for the initial video.

Open JorgeSivil opened this issue 4 years ago • 1 comments

If you have a video, and click on the starter (like an image), the event 'Played' is catch but not the 'Unstarted'

It is fired when you change the video ID tho.

I did this in vanilla javascript and it fires everytime, so I guess there's a bug somewhere.

Work around is to consider the "onReady" as "unstarted", as the onReady will fire only once the first time. A bit hacky tho.

function getPlayer(playerStatus) {
  return (
    <YouTube
      videoId={playerStatus.video.id}
      opts={{
        reset: true,
        playerVars: {
          autoplay: 1,
        },
      }}
      onReady={(event) => trackPlayerEvent(-1, event.target.playerInfo.videoData.video_id)}
      onStateChange={(event) => {
        trackPlayerEvent(event.data, event.target.playerInfo.videoData.video_id);
      }}
    />
  );
}

JorgeSivil avatar Aug 04 '20 19:08 JorgeSivil

@JorgeSivil Can you provide more context on what version of react-youtube you're using?

I created the following sandbox and looks like every player state is being triggered as expected.

https://user-images.githubusercontent.com/7356098/105629002-58725700-5e38-11eb-98a8-4c4c5dcfa584.mp4

ruisaraiva19 avatar Jan 24 '21 11:01 ruisaraiva19