• 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?

    https://wordpress.org/plugins/youtube-embed-plus/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter john smith

    (@nanquan491)

    Hi, I really REALLY need this to work… can you PLEASE help?

    Thread Starter john smith

    (@nanquan491)

    Does anyone actually even check this forum?

    Thread Starter john smith

    (@nanquan491)

    Hello?

    Plugin Author embedplus

    (@embedplus)

    Unfortunately we don’t support requests for arbitrary custom user Javascript code external from our plugin. We’d never be able to answer everyone’s questions, much less have time to keep the plugin up-to-date with new features. Hopefully you can understand that. If you’re interested in manipulating embeds somehow with Google’s YouTube API, we’d suggest first learning how to get things working on a single, plain, non-WordPress HTML page that just has a single YouTube video on it, and follow the documentation here: https://developers.google.com/youtube/iframe_api_reference#Getting_Started Once you learn how the API works plainly outside of WordPress and without a plugin, you should be able to apply what you learn to your real website. Also, Googling “youtube api existing iframe” might help.

    -EmbedPlus Team

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to call YouTube API events (like 'onStateChange')’ is closed to new replies.