Play a midi file (.mid) on your browser (HTML).

vegaseat 0 Tallied Votes 4K Views Share

Lots of good instrumental music out on the web in the form of midi files. You can incorporate background music as part of your web page. Here is the short code.


<!-- Experiments with midi sound    vegaseat  -->
<!-- embed src, hidden, autostart, loop -->


  <TITLE>Embedded MIDI</TITLE>


<body bgcolor="#FFFF00" text="#FF66CC">

<h2>This starts the midi file automatically!</h2>

<!-- the given midi file comes with Win XP, you may need to change this -->
<!-- to something you have!!!!!!!!!! -->
<!-- hide play buttons, autostart and loop once -->
<EMBED SRC="C:\Windows\Media\Onestop.mid" hidden=true autostart=true loop=1>

EdgarSwank 0 Newbie Poster

Does not work for me.

Matthew N. 0 Junior Poster in Training

Does not work for me.

Do you have windows (any version) as this will not work unless you change the path if you are not using windows

<EMBED SRC="C:\Windows\Media\Onestop.mid" hidden=true autostart=true loop=1>

Change to a absolute url to the file or to the folder it is in.

EdgarSwank 0 Newbie Poster

I already changed that to the absolute URL I wanted.

When I use your suggestion, Firefox says to click to download plugin, but when I do it says not available. When I click manual install, it just re-installs Quicktime I already have installed, but Embed still doesn't work.

I also tried IE, but it wants to install a RealPlayer plugin, which it can't find either.

I've searched for a solution, but all discussion appears to be years old. Years ago, Embeds of MID files worked OK for me, but then they stopped working. If you have something that works today with either FireFox or Seamonkey, I would be eternally grateful.

Arkinder 93 Posting Pro in Training

Your code is deprecated, and your method is outdated. NO ONE should use this.

Regards, Arkinder

EdgarSwank 0 Newbie Poster

If this method of playing MIDI files is outdated, then what is the current method? Is it possible to play MIDI files via HTML at all?

Johannes_2 0 Newbie Poster

Browsers dropped support for playing MIDI files natively over time. You might want to try MIDI.js, a JavaScript based cross browser library.

Add the MIDI.js script to your webpage:

    <script type='text/javascript' src=''></script>

Add a link to start playing:

    <a href="#" onClick="'path/to/yoursong.midi');">Play My Song</a>

Take a look at for details.

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.