Skip to main content

Posts

Showing posts from September, 2016

YouTube Player API Reference for iframe Embeds

YouTube Player API Reference for iframe Embeds The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript.Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played. <script>       // 1. This code loads the IFrame Player API code asynchronously.     var tag = document.createElement('script');     tag.src = "https://www.youtube.com/iframe_api";     var firstScriptTag = document.getElementsByTagName('script')[0];     firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);     // 2. This function creates an <iframe> (and YouTube player)     //    after the API code downloads.     var player;            function onPlayerReady(event) {         event.target.playVideo();     }           var done = false;     function onPlayerStateChange(eve