Hi. I am a relative noob when it comes to javascript and flash. I have been looking at some examples and was able to get Media Player 4.3 to work with a XSPF playlist. I need the ability for Media Player to reload the playlist if it finds an updated playlist. I have been using a meta refresh to reload the page and playlist but I don't like this solution. I did a search and did not find many posts related to this. The few posts that I did find seemed to be talking about Media Player 3.X.
I am attaching a copy of my html. I would greatly appreciate any help I can get. The more detailed the response, the better...since I really don't know what I am doing. Thanks in advance!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="300">
<title>Test Page</title>
<style type="text/css">
body { background-color: #000000; color:#000000; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px;}
</style>
</head>
<body>
<div id='player1' style="position:absolute; top:10px; left:10px">This is player1</div>
<script type='text/javascript' src='swfobject.js'></script>
<script type='text/javascript'>
var s1 = new SWFObject('player.swf','player1','640','400','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=list.xspf&autostart=true&repeat=list&repeat=always&icons=false&bufferlength=1&stretching=exactfit');
s1.write('player1');
</script>
</body>
</html>

This code uses a timer to reload the playlist every nn seconds —OR— it checks the file modified time of the playlist and reloads the playlist on completion of the currently playing item, if the playlist has been updated.
It's v3.x player code. If I can find the time later, I'll update it for the v4.x JW FLV Media Player.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Reload Playlist Every 60s -or- If Playlist Has Been Updated - JWMP v3.x - swfobject v2.2</title>
<script type="text/javascript" src="swfobject-2.2.js"></script>
<!-- inline script #1 - AJAX -->
<script type="text/javascript">
var xmlhttp = false;
var lastModified = null;
var playlistUpdated = false;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
xmlhttp = false;
}
}
if(!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch(e)
{
xmlhttp = false;
}
}
if(!xmlhttp && window.createRequest)
{
try
{
xmlhttp = window.createRequest();
}
catch(e)
{
xmlhttp = false;
}
}
function checkFileUpdate(file)
{
xmlhttp.open('HEAD', file, true);
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4)
{
if((lastModified != null) && (lastModified != xmlhttp.getResponseHeader('Last-Modified')))
{
alert('File was last modified on: ' + xmlhttp.getResponseHeader('Last-Modified'));
lastModified = xmlhttp.getResponseHeader('Last-Modified');
playlistUpdated = true;
}
lastModified = xmlhttp.getResponseHeader('Last-Modified');
}
}
xmlhttp.send(null)
setTimeout("checkFileUpdate('playlist.xml')", 60000);
};
// start loop timer
setTimeout("checkFileUpdate('playlist.xml')", 60000);
</script>
<!-- inline script #2 - Player API -->
<script type="text/javascript">
var currentItem = 0;
var startItem = 0;
function getUpdate(typ, pr1, pr2, pid)
{
if(typ == 'item')
{
currentItem = pr1;
}
// reload playlist on completion of current item only if playlist has been updated
if((typ == 'state') && (pr1 == 3) && playlistUpdated)
{
gid('playerId').loadFile({file:'playlist.xml'});
//alert('playlistUpdated: ' + playlistUpdated);
playlistUpdated = false;
}
};
// playlist reload loop timer
function reloadPlaylist()
{
gid('playerId').loadFile({file:'playlist.xml'});
startItem = currentItem;
setTimeout("gid('playerId').sendEvent('playitem', startItem)", 750);
setTimeout("reloadPlaylist()", 60000);
};
// start loop timer
//setTimeout("reloadPlaylist()", 60000);
function gid(name)
{
return document.getElementById(name);
};
</script>
<!-- inline script #3 - Player -->
<script type="text/javascript">
var flashvars =
{
file: 'playlist.xml',
width: '400',
height: '443',
displayheight: '300',
enablejs: 'true',
javascriptid: 'playerId',
overstretch: 'fit',
repeat: 'true',
shuffle: 'false',
autostart: 'true'
};
var params =
{
allowscriptaccess: 'always',
allowfullscreen: 'true'
};
var attributes =
{
id: 'playerId',
name: 'playerId'
};
swfobject.embedSWF('mediaplayer.swf', 'player', '400', '443', '9.0.124', false, flashvars, params, attributes);
</script>
</head>
<body>
<div id="playercontainer" class="playercontainer">
<a id="player" class="player" href='http://www.macromedia.com/go/getflashplayer'>get the flash player to see this player.</a>
</div>
</body>
</html>