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=”http://www.yourwebsite.com/audiofolder/youraudio.mp3″ 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.

52 Responses to “HTML Code to Auto-Play MP3 Audio Files”

  1. Nam says:

    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,

  2. askland says:

    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 MySpace.com 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.

  3. Mike says:

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

  4. Mike says:

    The tag?

  5. Mike says:

    It’s

    the PRE tag.

    > pre

  6. christians says:

    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.

  7. Tobi says:

    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??

  8. Josh says:

    That’s what I coded from what you posted.

  9. Josh says:

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

    – Had to re-edit it

  10. Steven says:

    That works for me, thanks!

  11. Tom says:

    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?

  12. Baiju Sultan says:

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

  13. Atlantis says:

    but where do u get the code of the songs

  14. Rob says:

    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.

  15. jacksen says:

    thanks.you good man

  16. jacksen says:

    to atlantis,
    if you want you can go to youtube.com
    its free

  17. Kebie says:

    Thanks, It helped me a lot!!!

  18. agung says:

    thanx, it useful

  19. Ruby says:

    To Atlantis:

    if you want to get a URL for the song you want to play, go to http://boxstr.com/

    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.

    (:

  20. Ruby says:

    Oops. I meant, the code i used was:

  21. Ruby says:

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

  22. Fergus says:

    Cheers buddy, very useful.

  23. pumab says:

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

  24. ken says:

    hey thanks! it’ work

  25. gg says:

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

  26. Jaime says:

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

  27. chris says:

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

  28. ajans says:

    hey thanks! it’ work

  29. Anonymous says:

    JUST REPLACE THE MP3 URL

  30. dizree says:

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

  31. dizree says:

    embed src=”example.mp3″???

  32. Anonymous says:

    It works perfectly, many thanks!

  33. Gwendolyn Smith says:

    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.

  34. askland says:

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

  35. Blake says:

    wtf is the unicode error about?

  36. CMonster95 says:

    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.

  37. Kimberly says:

    Thanks for the script. It works. :-)

  38. Anonymous says:

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

  39. joe says:

    not effective..how you did it..?

  40. Matt says:

    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.

  41. sanya says:

    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!

  42. vedant says:

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

  43. §chame says:

    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.

  44. Priyanshu says:

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

  45. Tirupati Darshan says:

    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.

  46. easter says:

    use blocks ..

  47. Camelia says:

    THX SO MUCH thats really helpfull :DD

  48. Lekitra says:

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

  49. Nauman says:

    it is not working on my Facebook Fanpage

    this is how i make plz help

  50. Nauman says:

    src=”http://sound2.mp3pk.com/indian/zakham/zakham4.mp3″ loop=”true”
    autoplay=”false” width=”145″ hieght=”60″

    this is the code plz help

  51. Jing says:

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

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>