i tried to start (pre)loading a video right after the player is initialized - so that visitors with a slow internet connection are also able to watch the video smoothly when pressing PLAY.
on my site i would suggest that visitors would normally read some text before they would press the play-button (the video is below the fold...)
so i tried this:
--- code ---
<script type="text/javascript" src="http://www.jeroenwijering.com/embed/swfobject.js"></script>
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('/fileadmin/user_upload/videos/player.swf','myplayer','950','534','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('wmode','opaque');
so.addParam('flashvars','&file=http://www.mysite.com/fileadmin/user_upload/videos/kopfvideos/test.flv&controlbar=over&icons=true&di...');
so.write('player');
// initialize and preload
var player;
function playerReady(obj) {
player = document.getElementById(obj['id']);
};
player.sendEvent('LOAD','http://www.mysite.com/fileadmin/user_upload/videos/kopfvideos/test.flv');
</script>
--- /code---
unfortunatelly it does not work. if i press my PLAY-button, wich calls player.sendEvent('PLAY','true'); i can see that the video is not (pre)loaded yet...
what is my problem? can anybody help? thanks!
You need to add a Model Listener TIME, start playing the media file, then as soon as the position is greater than zero (indicating that the video has started), PAUSE the player and let it buffer.
autostart=true—UNTESTED— but should be close.
<script type="text/javascript">var player = null;
var bufferFlag = true;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
// I suppose this should really should be checking the property to see if it's type "object'
if(player.getPlaylist())
{
player.addModelListener('TIME', 'timeMonitor');
}
else
{
setTimeout("addListeners()", 100);
}
};
function timeMonitor(obj)
{
if((obj.position > 0) && (bufferFlag))
{
player.sendEvent('PLAY', 'false');
bufferFlag = false;
};
function gid(name)
{
return document.getElementById(name);
};
</script>