I am using the following code to embedd 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 FF, however, a pop-up appears that says additional plug-ins are needed. When I click on the option to install additional plug-in, it doesnt 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 embedd mp3, or a fix to this problem???

Thanks!!!!

Dani AI

Generated

A practical, modern fix for the issues described is to stop using plugin-based embedding and use the HTML5 audio element. Native audio avoids plugin prompts in Firefox, gives consistent controls, and lets you explicitly avoid autoplay. A minimal example (replace the filenames):

<audio controls preload="none">
  <source src="yourfile.mp3" type="audio/mpeg">
  <source src="yourfile.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

Use preload="none" and do not include an autoplay attribute. If an older browser still starts playback unexpectedly, force-stop it on load:

<script>
window.addEventListener('load', function () {
  var a = document.querySelector('audio');
  if (a && !a.paused) { a.pause(); a.currentTime = 0; }
});
</script>

If you tried a third-party player as suggested and saw certificate warnings (as did), check that the page and any player assets are served over HTTPS to avoid mixed-content or installer trust problems. For broad compatibility serve at least MP3 plus OGG fallbacks (older Firefox historically handled MP3 differently). For a consistent UI and graceful fallbacks consider a maintained library such as MediaElement.js. See the HTML5 audio docs and mixed-content guidance for details: HTML audio element docs and Mixed content.

Recommended Answers

All 3 Replies

The easist way is to use Yahoo's web player. you'll get the most compatibility using this.

http://webplayer.yahoo.com/

JorgeM,
I tried this already, and both IE and FF have a security message that blocks the media from playing.
Any idea how to work around it?

?? hmmm. I haven't seen that. I'll look into this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.