user828640
user828640

Reputation: 81

Embed mp3 file into html that works across browsers

I am using the following code to embed an mp3 file into my html document:

 <embed src="aharddaysnight.mp3" width="140" height="40" autostart="false" loop="FALSE"></embed>

In IE, this works fine, as an mp3 player with controls automatically shows up.

In FireFox, however, a pop-up appears that says additional plug-ins are needed. When I click on the option to install additional plug-in, it doesn't allow me to because of a security certificate error.

In Chrome, the player shows up, but the media starts playing automatically, even though the code says autostart "false".

Does anyone have a better way to embed mp3, or a fix to this problem?

Upvotes: 4

Views: 29977

Answers (2)

user2455581
user2455581

Reputation: 11

Try this

type="audio/mpeg" 

OR

type="audio/midi"

Upvotes: 1

Tracy Burnley
Tracy Burnley

Reputation: 21

I have tested this in Chrome and Firefox and works in both, with the fall back. However if it is a long file, like the 2 hour audio I am trying it stops playing. Hopefully it will help you and I will keep looking for my fix.

<audio controls="controls">
 <source src="yourURL.mp3" />
 <source src="yourURL.ogg" />
 <!-- fallback -->
  <embed type="application/x-shockwave-flash"                                                         
    flashvars="audioUrl=yourURL.mp3"    
     src="http://www.google.com/reader/ui/3523697345-audio-player.swf"   
     width="650? height="0? quality="best"></embed>
</audio>`

Upvotes: 2

Related Questions