0

Using YouTube's JavaScript API to control an iFrame embed. I've set up the functions and don't see any errors... but I'm not logging the API's initialization as documented here.

Yes, it's running off a server, not locally: http://jp.redwoodmatthews.com

Am I missing something? HTML and JavaScript below! Thanks for your help.


iFrame HTML:

<iframe id="ryanBingham" src="http://www.youtube.com/v/Xz5SNppHRxc?rel=0?enablejsapi=1&version=3&playerapiid=video" frameborder="0"></iframe>

JavaScript:

function onYouTubePlayerReady(playerId) {
    video = document.getElementById('ryanBingham');

    video.addEventListener('onStateChange', 'onytplayerStateChange');

    console.log('YouTube API initiated');
}

1 Answer 1

1

You're on the wrong API docs. This is for iframes: https://developers.google.com/youtube/iframe_api_reference

Due to same origin restrictions, it works a bit differently. Also, the ready function is named onYouTubeIframeAPIReady.

Last but not least, make sure you load the API JS file

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.