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

vegaseat

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.

2,837 Views
About the Author

Scientist

<HTML>

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

<HEAD>

  <TITLE>Embedded MIDI</TITLE>

</HEAD>

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

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

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

</body>
</HTML>
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.

http://americancryonics.org/caldream.mid

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='http://www.midijs.net/lib/midi.js'></script>

Add a link to start playing:

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

Take a look at http://www.midjs.net for details.

Be a part of the DaniWeb community

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