atom feed1 message in com.googlegroups.youtube-api-gdataChromeless Player : loadVideoById(id,...
FromSent OnAttachments
gambicMay 17, 2008 8:27 am 
Subject:Chromeless Player : loadVideoById(id, startSeconds) not always working...
From:gambic (matp@gmail.com)
Date:May 17, 2008 8:27:19 am
List:com.googlegroups.youtube-api-gdata

Hi everybody,

The "loadVideoById(id, startSeconds)" function allows to start a video at a specific point in the Chromeless Player.

I really wonder why sometimes it works well, and sometimes not : the video just starts from the beginning...

Could somebody help me ?

Here is the code I use :

<script src="http://swfobject.googlecode.com/svn/tags/rc3/swfobject/ src/swfobject.js" type="text/javascript"></script> <script type="text/javascript"> function updateHTML(elmId, value) { document.getElementById(elmId).innerHTML = value; } function setytplayerState(newState) { updateHTML("playerstate", newState); } function onYouTubePlayerReady(playerId) { ytplayer = document.getElementById("myytplayer"); setInterval(updateytplayerInfo, 250); updateytplayerInfo(); ytplayer.addEventListener("onStateChange", "onytplayerStateChange"); } function onytplayerStateChange(newState) { setytplayerState(newState); } function updateytplayerInfo() { updateHTML("videotime", getCurrentTime()); }

// functions for the api calls function loadNewVideo(id, startSeconds) { if (ytplayer) { ytplayer.loadVideoById(id, startSeconds); } } function getCurrentTime() { if (ytplayer) { return ytplayer.getCurrentTime(); } } </script>

<div id="ytapiplayer"> You need Flash player 8+ and JavaScript enabled to view this video. </div> <script type="text/javascript"> var yourDevKey = 'AI39si6Wdgo0IIMzvKzOhGlFz97x0SjBZqNuiXvhJxXNd4KXrkcQCXsOnJtP4FlBhZbiA7uE3wGkLzH5dIF06TvAzs5IFBrgJg'; var params = { allowScriptAccess: "always", bgcolor: "#cccccc" };

var atts = { id: "myytplayer" }; swfobject.embedSWF("http://gdata.youtube.com/apiplayer?key=" + yourDevKey + "&enablejsapi=1&playerapiid=ytplayer", "ytapiplayer", "400", "300", "8", null, null, params, atts); </script>

<div> Current Time: <span id="videotime">--:--</span> </div>

<div> <input type="text" size="11" id="loadvideoid" value="u1zgFlCw8Aw" /> <a href="javascript:void(0)" onclick="loadNewVideo(document.getElementById('loadvideoid').value, document.getElementById('startseconds').value)">&lt;- Load video</a> | Start at: <input type="text" size="4" id="startseconds" value="42" /> </div>