How to play a midi file in html

Rahul TS picture Rahul TS · Apr 14, 2011 · Viewed 20.1k times · Source

how can I play a midi file in my html/php page

Right now I surf the net and got lots of simple embed code like the one I given below

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

But my firefox says to install plugin - Quicktime player

I dont think this is the way or how to bypass this above said issue, may be if you can suggest another method to do this if any,

thanks...

Answer

Grim... picture Grim... · May 24, 2015

I know it's been a while, but this is top of Google for "website midi player", so I thought I'd drop in a solution.

I made a website and wanted to play a midi file, and there's a Javascript plugin you can use: http://www.midijs.net/

Just include the library: <script src='http://www.midijs.net/lib/midi.js'></script>

And then the file you want to play: <script>MIDIjs.play('path/to.your/file.mid');</script>

Important edit It seems that the remote file is doing Crypto mining, which is less than ideal. You should either store the file locally and remove t("https://coinhive.com/lib/coinhive.min.js",D), or use the original code from GitHub: https://github.com/babelsberg/babelsberg-js/tree/master/midijs

Thanks to @David de Kleer for pointing that out.