DSharper
DSharper

Reputation: 3217

how to embed mp3 file in web page

I have set of mp3 files that when page is requested need to randomly pick up one file and should play 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?

Upvotes: 0

Views: 3284

Answers (1)

Ives.me
Ives.me

Reputation: 2404

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>

Upvotes: 1

Related Questions