#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Cool Call an iframe's function based on YouTube player status


    On my website I have an embedded YouTube player on one of my top page slides. When the video status is 'playing', I want to target an iframe within my page and call a 'pauseS()' in it. This unfortunately isn't working on its own either:
    Code:
    document.getElementById('player').contentWindow.pauseS();
    When the YouTube player is paused or ends, I want to call a different function:
    Code:
    document.getElementById('player').contentWindow.playS();
    How can I script this? I've included a jsfiddle:
    http://jsfiddle.net/JvE7S/
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,188
    Rep Power
    184
    YouTube has a JavaScript API, that takes advantage of the "onStateChange" event for their video player; here is the documentation. That should help you do what your wanting to do; once you understand how these events work.

    Good Luck

IMN logo majestic logo threadwatch logo seochat tools logo