It does seem wasteful but, it may not be. You could just do like:
Code:
<script type="text/javascript">
function play(media)
{
if (media=='stop.jpg')
document.getElementById('mediaplayer').innerHTML='<img src="stop.jpg">'
else
document.getElementById('mediaplayer').innerHTML='<object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95"'
+'type="application/x-oleobject" width="0" height="0"><param name="fileName" value="'+media+'">'
+'<embed type="application/x-mplayer2" src="'+media+'" width="0" height="0"><\/embed><\/object>'
}
</script>
in the html...
<ul>
<li><a onclick="play(this.href);return false" href="http://www.r2.co.nz/meta/coolblue-128.asx">Jazz</a></li>
<li><a onclick="play(this.href);return false" href="http://www.novaclassicrock.nl/nova_classic_rock_player.asx">Classic Rock</a></li>
...etc.
<li><a onclick="play(this.href);return false" href="stop.jpg">Stop</a></li>
</ul>
Also, there probably is a parameter for stoped or a play=false or something like that and a corresponding attribute for the embed tag (Google would be a good resource for finding those). If so, you could query the element for its current embed tag's src before writing to it with the same src, but in stop mode.
Note: This whole scheme would be better using links to the players on separate pages to be shown through an iframe. That way non-javascript enabled browsers would have a very good shot at getting the content in its intended presentational form. As it is now, one just has to hope that clicking on a link to an asx file will launch the non-javascript enabled client's own player.
Bookmarks