simple midi.js Player example

4k Views Asked by At

I have been looking all over, but I can not seem to find a simple Player example for midi.js http://mudcu.be/midi-js/ .

The Player example is so complex I cannot get it to work in my page....What am I missing?

 <script src="./js/MIDI/AudioDetect.js" type="text/javascript"></script>
 <script src="./js/MIDI/LoadPlugin.js" type="text/javascript"></script>
 <script src="./js/MIDI/Plugin.js" type="text/javascript"></script>
 <script src="./js/MIDI/Player.js" type="text/javascript"></script>
 <script src="./js/Window/DOMLoader.XMLHttp.js" type="text/javascript"></script>
 <!-- extras -->
<script src="./inc/Base64.js" type="text/javascript"></script>
<script src="./inc/base64binary.js" type="text/javascript"></script>

  <script type="text/javascript">
 MIDI.Player.loadFile("start.mid",MIDI.Player.start);
 MIDI.Player.start();

 </script>
1

There are 1 best solutions below

0
On BEST ANSWER

You missed some imports. For a midi player, you should use the script tags from the demo-MIDIPlayer.html file.

<script src="./js/MIDI/AudioDetect.js" type="text/javascript"></script>
<script src="./js/MIDI/LoadPlugin.js" type="text/javascript"></script>
<script src="./js/MIDI/Plugin.js" type="text/javascript"></script>
<script src="./js/MIDI/Player.js" type="text/javascript"></script>
<script src="./js/Widgets/Loader.js" type="text/javascript"></script>
<script src="./js/Window/Event.js" type="text/javascript"></script>
<script src="./js/Window/DOMLoader.XMLHttp.js" type="text/javascript"></script>
<!-- jasmid package -->
<script src="./inc/jasmid/stream.js"></script>
<script src="./inc/jasmid/midifile.js"></script>
<script src="./inc/jasmid/replayer.js"></script>
<!-- extras -->
<script src="./inc/Base64.js" type="text/javascript"></script>
<script src="./inc/base64binary.js" type="text/javascript"></script>

Also, you need to load the plugin, before you can start playing a file.

window.onload = function () {
    MIDI.loadPlugin({
        callback: function() {
            MIDI.Player.loadFile("start.mid", MIDI.Player.start);
        }
    });
}