Forum Moderators: open

Message Too Old, No Replies

Embed an MP3

         

almo136

8:36 pm on Apr 16, 2009 (gmt 0)

10+ Year Member



Hi,

I'd like to embed an mp3 file into a web page so users can select to play a song.

What's the best way to code this to work with quicktime by default or windows media player if quicktime isn't installed?

Thanks!

mcneely

10:55 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'll be using MediaPlayer in this instance;

Load your media file to your server root, or subdirectory.

Then copy the address (url) to your media file and paste it into notepad ... it will look like this;
example.com/example/example.mp3

Then name the notepad document anything-you-like with a .m3u extention (songs.m3u)

Load the .m3u file to your server, into the same folder/directory that your actual song or media is in.

Next comes your object;

<OBJECT ID="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701" STANDBY="Loading Microsoft Windows® Media Player components..." TYPE="application/x-oleobject" width="280" height="46">
<param name="fileName" value="http://www.example.com/example/anything-you-like.m3u">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="true">
<param name="showControls" value="true">
<param name="Volume" value="-300">
<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="http://www.example.com/example/anything-you-like.m3u" name="MediaPlayer1" width=280 height=46 autostart=1 showcontrols=1 volume=-300>
</OBJECT>

If you don't want the media to begin playing on the pageload, simply change the parameter "autostart" from true to false.

Next, you'll copy the code above, and paste it to where ever in the page code you like.

dreamcatcher

6:45 am on Apr 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also use a flash player.

dc