页面mp3播放器作
HTML代码:
<div><!-- 隐藏播放器,设置高宽为0--><object name="playerIE" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902"standby="Loading Microsoft Windows Media Player..." type="application/x-oleobject" width="220" height="40" > <param name="FileName" value=""><param name="autoStart" value="true"><param name="showControls" value="true"><!-- 自动重复 --><param name="loop" value="false"> <embed id="playerFF" src="audio/niftyPlayer.swf?file=''" width="220" height="40" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed></object></div><button onclick="Play();">Play</button>
function Play(){var isIE = navigator.appName.indexOf("Microsoft");var player = 'audio/niftyPlayer.swf';function changeMusic(musicUrl){var media ;if(isIE < 0){media = document.getElementById("playerFF");//(参数由所使用的flash播放器决定):audio/niftyPlayer.swf?file=music02.mp3&as=1;media.src = player + '?file=' + musicUrl + '&as=1';}else{media = window.playerIE;media.setAttribute('FileName',musicUrl);}};changeMusic('audio/yu.mp3');};