Dave's Brain

Browse - Programming Tips - What's the best way to embed an MP3 track in a page?

Date: 2010jan20
Language: html
Platform: web
Warning: Use the <audio> tag now
Keywords: music, song

Q.  What's the best way to embed an MP3 track in a page?

A.  I like this code because its pretty simple and seems
to work on nearly every browser:

$title<br> <object type="audio/x-mp3" data="$file" width="300" height="45"> <param name="src" value="$file"> <param name="autoplay" value="false"> <param name="autoStart" value="0"> <!- Fallback -> <a href="$file">Play &gt;</a> </object>
Replace $file with the path to you file - eg my_track.mp3 Replace $title with some text describing your track.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.