Nov. 05, 2009Emma paypal waiting
I have been using some very excellent code by mimi which seems to have stopped working with the latest swfobject or player - not sure which.
mimi coded in this thread
http://www.longtailvideo.com/support/forum/Setup-Problems/16501/Live-RMTP-stream-with-an-image-placeholder-#msg111980
and the code is below. Can anyone see what is wrong
http://www.mrsc.co.uk/flash/player.php
Fix this, make it work for me and post your email and I'll send you paypal $50 if you want - I'm in trouble
<script type="text/javascript">
var player = null;
var playlist = null;
var startFlag = true;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
playlist = player.getPlaylist();
if(playlist !== null)
{
player.addModelListener('TIME', 'timeMonitor');
loopie();
}
else
{
setTimeout("addListeners()", 100);
}
};
function timeMonitor(obj)
{
if((obj.position > 0) && (!startFlag))
{
startFlag = true;
}
};
function loopie()
{
if(!startFlag)
{
player.sendEvent('PLAY', 'true');
setTimeout("loopie()", 5000);
}
};
function gid(name)
{
return document.getElementById(name);
};
</script>
Nov. 05, 2009hobbs
startFlag should have been starting out as false. Did this ever work?
I'm gonna go give mimi a smack upside the head! (Just kidding.)
Try this:
<script type="text/javascript">
var player = null;
var playlist = null;
var startFlag = false;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
playlist = player.getPlaylist();
if(playlist !== null)
{
player.addModelListener('TIME', 'timeMonitor');
loopie();
}
else
{
setTimeout("addListeners()", 100);
}
};
function timeMonitor(obj)
{
if((obj.position > 0) && (!startFlag))
{
startFlag = true;
}
};
function loopie()
{
alert('loopie():\nstartFlag: ' + startFlag);
if(!startFlag)
{
player.sendEvent('PLAY', 'true');
setTimeout("loopie()", 5000);
}
};
function gid(name)
{
return document.getElementById(name);
};
</script>
Test Page: http://willswonders.myip.org:8074/Emma.html
Once your stream becomes available, it should play and the incredibly annoying alert will stop popping up.
Nov. 05, 2009Emma paypal wait
It did work, once
What it was doing was sitting there silently polling waiting for the file to become available, then autostarting the stream, which won't exist until the stream starts.
Could you possibly make it work like this, without any popups? Can't live with the popup....
Thankyou
Emma
Nov. 05, 2009hobbs
Just comment out (with "//") or delete the alert://alert('loopie():\nstartFlag: ' + startFlag);
The alert is only for testing, to confirm that the loop is trying to connect every 5 seconds. Once the player connects, the alert won't popup.
Nov. 05, 2009Emma paypal wait
Yes, brilliant almost there - but the placeholder image now flashes everytime there's a poll for the file, it wasn't doing this before any way to stop this?
Thaks so much,
Emma
Nov. 05, 2009hobbs
That's the normal behavior for the player.
When it's trying to load a stream, the preview image disappears and the buffering icon shows (yours is turned off), then when the stream can't be found, the player stops and shows the preview image again.
The behavior that you were seeing before was because the player was continuously trying to load the stream, until the stream became available.
As soon as I get my RTMP server up, I'll do some more testing, possibly with other releases of the player, to see if there is a way to have the preview image show continuously until the stream starts playing.
Nov. 05, 2009Emma paypal wait
No - its fixed, thankyou thankyou. Can I express my thanks as promised? I and I might periodically need help anyway w. javascripting email removed as its now doa
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.