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.
<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&enablejsapi=1&playerapiid=ytplayer", "ytapiplayer", "425", "344", "8", null, null, params, atts); //]]> </script>
Download sample code below…