I have set of mp3 files that when page is requested need to randomly pick up one file and should pl开发者_运维问答ay as background music in my web page is there a cross browser way(need to work major web browsers such as IE,firefox,chrome) of doing this?
Use JW Player http://www.longtailvideo.com/players/jw-flv-player/ to play MP3, but please don't play music without the user request. This will make the user to GTFO of your website.
Example: http://www.longtailvideo.com/support/jw-player-setup-wizard?example=202
<script type='text/javascript' src='swfobject.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
var so = new SWFObject('player.swf','mpl','470','24','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('duration','33');
so.addVariable('file','http://www.longtailvideo.com/jw/upload/bunny.mp3');
so.write('mediaspace');
</script>
精彩评论