0
votes

I'm experimenting with the Iframe youtube api and am not able to run the code directly from their getting started documentation.

Here is the code: http://jsfiddle.net/ApK7X/1/

It is suppose to load the player, play it and also update section with id embed-code however, all its doing is showing the player. It does not automatically play the video, nor does it update the id on the page.

What gives?

1
Your code never does anything, because you never run your functions... - Jasper
...aren't they called by the api? Also figured out that part of my problem is that this does not work on local static html pages. the pages need to be running on a server... - Anthony
Here is an updated version of your JSFiddle where I put alerts in the functions, and you will notice that they don't fire: jsfiddle.net/ApK7X/3 - Jasper

1 Answers

2
votes

You have to:

  1. Include the API at your code.
  2. Remove &origin=http://example.com. By specifying this parameter, the API will only work at http://example.com, not at any other protocols or domains.
  3. In the fiddle, change Onload to nowrap (head), so that your API methods are defined in the global namespace.

Working fiddle: http://jsfiddle.net/ApK7X/2/

For other implementation methods, have a look at one of these answers.