Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play a midi file in html

Tags:

html

midi

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

like image 585
Rahul TS Avatar asked Apr 14 '11 11:04

Rahul TS


People also ask

Can MIDI play HTML?

The html-midi-player package provides the <midi-player> and <midi-visualizer> HTML elements, which make it easy to play and display MIDI files on the web – no JavaScript coding required. See the GitHub repository for how to use it on your website, or try it on your MIDI files here.

Can Chrome play MIDI files?

To answer it simply, NO because . mid or MIDI file contains the steps and patterns of a musical instrument being played and not the sounds of the instrument when that pattern is being played. @rsp explains it well on StackOverflow in this Post. Any way to play these .

How do I play a MIDI file?

How to Play MIDI Files. MIDI files can be opened with Windows Media Player, VLC, WildMidi, TiMidity++, NoteWorthy Composer, WildMIDI, Synthesia, MuseScore, Amarok, Apple's Logic Pro, and very likely some other popular media players.

How can I add MIDI music to my Web page?

The code is simple -- just copy and paste it directly into your HTML code, then add your own MIDI files. Again, you can find MIDI files by visiting any number of MIDI archives on the Web, including those listed earlier in this chapter.


1 Answers

With html-midi-player, it is possible to embed a MIDI file in a website simply by inserting a midi-player element (a custom HTML element which works a lot like the audio element, but for MIDI files):

<midi-player src="jazz.mid" sound-font></midi-player>

Complete demo:

<midi-player src="https://cdn.jsdelivr.net/gh/cifkao/html-midi-player@2b12128/jazz.mid" sound-font>
</midi-player>

<!-- The following needs to be inserted somewhere on the page for the player(s) to work. -->
<script src="https://cdn.jsdelivr.net/combine/npm/[email protected],npm/@magenta/[email protected]/es6/core.js,npm/focus-visible@5,npm/[email protected]"></script>

Full disclosure: I'm the author of html-midi-player.

The playback functionality is provided by Google's Magenta.js library. It's also possible to use Magenta.js directly to play MIDI files, but this requires a non-trivial amount of JavaScript coding, which is why I created html-midi-player.

like image 105
ondra.cifka Avatar answered Oct 27 '22 18:10

ondra.cifka