HTML Code to Auto-Play MP3 Audio Files

Autoplay of audio files has long been considered bad form for websites, but I just can’t help myself. It’s just too fun. I’ve set a piece to play at the entrance of my site and will setup a short audio sample to play on the front of my blog.

You don’t have to embed in a flash player, and you can call up whatever audio format you want (.wav, MP3. .ra, etc.). If you are super evil like me you can set the file to “hidden – true” so no one can turn the music off. My front page is a splash page so if people don’t like the song they can always click to another section.

Here’s the code to autoplay MP3 audio music files on your website page:

embed src=”″ loop=”true” autoplay=”false” width=”145″ height=”60″></embed


NOTE: You will need to put a “<” at the beginning of code and a “> ” at the end. I couldn’t post it with the tags because my blog think’s it is HTML code (which it is).

Autostart – is to automatically start the song playing.
Hidden – is setting for audio controls.
If control is hidden then dimensions are not shown anyway.
Replace URL with exact location of your audio file.


  • Hi, I’ve been trying to play mp3 at my Yahoo360 blog. So I was very glad to find your instruction. However, when I pasted your code in my blog, and tried to preview it, I saw nothing. Apparently Yahoo360 doesn’t recognize it.

    Do you know how to solve the problem?

    My sincere thanks,

  • If I post that code within a post here on my blog it won’t play either – I had to put it into the sidebar to make it play. I’ve tried it also on posts but won’t work either – Needs to be in the main source code of the page. Might not work as a blog post.

    Also, see the note on the post for the “< " and ">” symbols to be put on the outside of code.

    If you post it on a regular html page you have total control of, it should work. I had it running here for several days on my site, but took it down – I get too many hits and the audio was getting garbled from the bandwidth.

  • You do know that you can use the tag to display HTML as text?

  • It’s

    the PRE tag.

    > pre

  • i would like to know how can use this code html but with many songs, for example i would kie that in my website if you enter there, the music autostart but all the songs in order.

  • I get all of it but the “Embed xsrc=”
    What does that mean??
    Is there any way to write an html code for an audio file??

  • That’s what I coded from what you posted.

  • <embed src=’Music.wav’ autostart=’true’ volume=’90’ hidden=’TRUE’ height=’0′ width=’0′>

    – Had to re-edit it

  • That works for me, thanks!

  • hi i just use one of your Auto code i used it as you instructed on the website but it didn’t work would you tell me how can use a code on my blog so i can browse music from my computer to my we blog?

  • Thanks a lot, this code works fine for me ! Excellent !
    But it will not work in Firefox, that’s all

  • but where do u get the code of the songs

  • I don’t want my songs to autoplay, so i set the autoplay value to ‘false’ but for some reason on other computers it still autoplays, which is really annoying since I have three songs on the page. It works however (they don’t play automatically) fine on my computer. Can anyone help.

  • good man

  • to atlantis,
    if you want you can go to
    its free

  • Thanks, It helped me a lot!!!

  • thanx, it useful

  • To Atlantis:

    if you want to get a URL for the song you want to play, go to

    Make an account and upload your mp3 file.
    They then give you a url which links to the file.

    So, the code that i used was:

    That code makes the song on your page autoplay, and it is invisible. So its just a song playing in the background and no one can stop it. heheh.


  • Oops. I meant, the code i used was:

  • Okay.. my code isn’t working.. :s

  • Cheers buddy, very useful.

  • html code is messed up, pls i realy need an auto player =(

  • hey thanks! it’ work

  • hey man! many thanx for this! tried several pieces of code but none seemed to work until this one. really appreciate your postings!

  • Code works great, but when I adjust the volume number, there seems to be no change in volume. Is that a wordpress issue?

  • So i put this code in and nothing is happening… when i upload what song code do i use from the

  • hey thanks! it’ work


  • wtf in my html, i used mp3 will it look like : ????????????

  • embed src=”example.mp3″???

  • It works perfectly, many thanks!

  • Gwendolyn Smith

    I would like to post a music auto play on my wesite…I’m a novice at this and could use your help with an html code that works…Thanks in advance.

  • I fixed the code on this post – it had gotten garbled. Should work fine – just remember to add the opening “< " and ending ">“

  • wtf is the unicode error about?

  • Unicode error: it is either trying to tell you to choose the option or not to choose the option. In other words, if you are using notepad to code the html file, and it gives you the error, go to “File >> Save As.” When the dialog box comes up, choose bottom-most drop-down box. If “Unicode” was not selected, select it. If it was, select another encoding option.

  • Thanks for the script. It works. đŸ™‚

  • I could not under stand, how can i put auto play audio in my web site. not under standing those details- prithvi

  • not you did it..?

  • Note: if you copy and past the code from this site, you most likely need to edit the quotes around the code/tags.

    Just delete/backspace over his quote and type a new one.

    It’s an html character issue.

  • It works perfectly.

    However, there’s an additional line on the top-left almost completely piled behind the address bar, which I’m trying to remove it. This line happens only by Chrome, not being shown by IE9, Safari, or FireFox. Maybe, it’s a technical issue by the browser itself.

    FYI – the code doesn’t work with Opera.

    Thank you very much for the code. I like it!

  • i want to autoplay this video how can i do that?

  • 1.) Why will one browser play and not another?
    Check ur plugins and browser versions…
    You might not have the req plugs for the browser
    or it just might not support the audio… could be security
    settings and options inherent to the browser as well.

    2.) Why won’t it play in pages like my-crap-space & suck-book?
    Prolly a matter of inheritance… that is.. in multi-frame pages one frame is the “parent” frame (almost always site controlled) and the rest are considered child frames. As such permissions are limited. Not to mention a myriad of other security options sites use TO PREVENT such code from running where it opens the possibility for malicious activity.

  • should we make traffic signal program in html…..?
    if yes….how can we make?

  • Tirupati Darshan

    It works Perfectly to me In blogger as well I would like to do it in WordPress too, Could any one tell me How could we make it in wordpress.

  • use blocks ..

  • THX SO MUCH thats really helpfull :DD

  • you can use PRE or CODE tag on your post.
    like this

  • it is not working on my Facebook Fanpage

    this is how i make plz help

  • src=”″ loop=”true”
    autoplay=”false” width=”145″ hieght=”60″

    this is the code plz help

  • i want this music will autoplay in my website.. what is the missing code to run in my website:

  • Hi,
    Yup..thanks a lot this works…but what if we need to add multiple songs..can we do that by simply adding many scr????

    thank you..
    have a good day!!!!

Leave a Reply

Your email address will not be published.