YouTube JavaScript Player API

YouTube JavaScript API allows users to control the YouTube chromeless or embedded video players via JavaScript. JavaScript API have methods for play, pause, seek to a certain time in a video, set the volume, mute the player, and other useful functions.

YouTube Embedded JavaScript Player API

<script type="text/javascript">
      // <![CDATA[

      // allowScriptAccess must be set to allow the Javascript from one 
      // domain to access the swf on the youtube domain
      var params = { allowScriptAccess: "always", bgcolor: "#cccccc" };
      // this sets the id of the object or embed tag to 'myytplayer'.
      // You then use this id to access the swf and make calls to the player's API
      var atts = { id: "myytplayer" };
      swfobject.embedSWF("https://www.youtube.com/v/_qnpxu_KCdA?border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer",
                         "ytapiplayer", "425", "344", "8", null, null, params, atts);
      //]]>
    </script>

Download sample code below…

YouTube JavaScript Player API