How to call YouTube API events (like 'onStateChange')
-
Hi,
I’m trying to get YouTube API events to work, but with no luck.
I see from the source code that the IFRAME Player API is already integrated into each page by the plugin, however when I try to make a call to it, as such:
player.addEventListener("onStateChange", function(state){ if(state === 1){ alert("Video is Playing!"); } });
I get an error message saying ‘player’ is not defined. I of course only try to do this on pages where there’s an existing YouTube video that’s embedded.
My goal is to listen to the Paused or Ended events, so perform an action based on them.
Please help?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to call YouTube API events (like 'onStateChange')’ is closed to new replies.