YouTube Chromeless Player
by
, 08-26-2009 at 06:29 PM (69348 Views)
It's not directly obvious from this how we can:
- start a movie on page load (question asked by some people on different forums);
- specify the dimensions and position of the movies in percentages;
- make good use of the ytplayer functions.
Autoplay: something like
Size of movie in percentages (sort of):Code:function so_start() { loadNewVideo('lKq9_kk3Zbc', 20); } //IE needs some time window.onload=setTimeout('so_start()',2000)Left and top of movie:Code:Something like: var width_of_movie=screen.availWidth/1.33+"px" var height_of_movie=screen.availHeight/1.79+"px" and then: // <![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("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer", "ytapiplayer", width_of_movie, height_of_movie, "8", null, null, params, atts); //]]>ytplayer functions in a menu:Code:<div style="position:absolute;left:22%;top:10%;border:1px inset black"> <div id="ytapiplayer" > You need Flash player 8+ and JavaScript enabled to view this video. </div> <!-- Buttons etc. for the movie --> <div style="text-align: center; font-size:10px; border:1px outset silver; padding-bottom:3px; background:white;"> <a href="javascript:void(0);" onclick="play();"><img src='play.jpg' height='14' style='border:0' title='Play' alt=""></a> etc. </div> </div>DEMO here. See source for (manipulations of) other ytplayer functions, like the stop function (not so good in the original), functions for fast forward / backward, functions for going to the beginning / the end of the video.Code:<a href="javascript:void(0)" onclick="loadNewVideo('yGYQtNAHbX4', 10)">Mary Stuart<br>(direct start at 10 secs)</a><br><br> <a href="javascript:void(0)" onclick="cueNewVideo('lKq9_kk3Zbc', 80)">Zarathustra<br>(button start at 80 secs)</a><br><br> <a href="javascript:void(0)" onclick="loadNewVideo('-o2lYktVy3I', 0)">Lisitsa plays the piano</a>
===
Arie.