0
votes

I have a youtube player embed done with API as instructed in documentation. Player works fine, so far good. Next for analytics, I want to trigger an analytics event when the video has just started playing (like at clip 1 of video).

From documentation, I am able to read YT.PlayerState.PLAYING === event.data at onStateChange event. But this event is fired when user pauses and plays; skips to different clip and plays; video buffers and plays etc. I have to fire my analytics event ONLY when video just started to play at clip 1. Is there an event/way to check if video is playing from clip 1.

Note: I tried storing the previous states and then comparing. I dont feel it is a clean solution. Looking for a better way.

1
onStateChange if event.data === 1 test for a variable that you have set.StackSlave
No pls read, event.data === 1 is fired so many times within the video. I only want when played at clip 1.Saravana Prakash

1 Answers

0
votes

From the YouTube API, you can try updateTimerDisplay() to see if the video has started playing or use getCurentTime() to find how many seconds you are into the video.