YouTube iFrame-JavaScript API

RESPONSIVE. Default size: 854px x 480px


See "page source" to observe the coding in this.

Added some things from the example at developers.google.com/youtube/iframe_api_reference

Events Capture

onReady
onStateChange
onError



Oct 29, 2014: Few times, you'll notice this error on Chrome console:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('this_window_url')

It's filed there:
code.google.com/p/gdata-issues/issues/detail?id=5788
Update Feb 3, 2017: It's related to multiple devices casting (like wizard casting gardiumleviosa to bunch of things) plugin. Chrome has that feature, and YouTube player (HTML5) uses that by default. I haven't read the very detail, but the plugin isn't built-in, you need to add it manually to Chrome. Maybe. Gardiumleviosa, everybody.
You might be interested in these:
  • YouTube iframe API: how do I control a iframe player that's already in the HTML?
    stackoverflow.com/questions/7443578/youtube-iframe-api-how-do-i-control-a-iframe-player-thats-already-in-the-html
  • Force HTML5 video for embedded YouTube video:
    stackoverflow.com/questions/5845484/force-html5-youtube-video