I have a music player in my site, here is the code:
<!-- player -->
<div id="player">
<div class="playerIcon"><img src="../img/musicIcon.gif" alt="" width="21" height="19" border="0"></div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="30" height="30" id="player1">
<PARAM NAME=movie VALUE="audioplay.swf?playerid=1">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=wmode VALUE="transparent">
<PARAM NAME="allowScriptAccess" value="always" />
<embed wmode="transparent" src="audioplay.swf?playerid=1" quality=high width="30" height="30" name="player1" allowScriptAccess="always"
align="" TYPE="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<script language="javascript">
function getPlayer(movieName){
i开发者_JAVA技巧f (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];}
else {
return document[movieName];
}
}
function play1() {
getPlayer('player1').playMusic();
}
function stop1(){
getPlayer('player1').stopMusic();
}
</script>
</div>
<!-- end player -->
Here, player1 has its own icon and also on-off state when click to pause music. I'd like to change also animated musicIcon.gif img to non-animated one when i click player icon. How can i do this? Thanks and regards
Can you put a click listener on the object element? When called, it should look at the state of the movie and if it's stopped, replace <img src="..." ...>
with the static image. If it's running, use the animated one.
You could also have both images in the page already and just toggle their .style.display property between 'none' and '' (empty string).
精彩评论