Demo: play MIDI files using MIDI.js
Add this in Global JavaScript
// https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file
function dynamicallyLoadScript(url) {
var script = document.createElement("script"); // create a script DOM node
script.src = url; // set its src to the provided URL
document.head.appendChild(script); // add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead)
}
function ggbOnInit() {
if (window) {
var url = "https://www.midijs.net/lib/midi.js";
dynamicallyLoadScript(url);
}
}
Then add this in a Button (as JavaScript)
// encode MIDI file here http://jpillora.com/base64-encoder
var dataUrl = "data:audio/mid;base64,TVRoZAAAAAYAAQACAHhNVHJrAAAAGQD/WAQEAhgIAP9ZAgAAAP9RAwehIAD/LwBNVHJrAAAAnADALgCQPX80kD9/AoA9AD7ANwCQQn87gD8AQIBCAALALgCQPX8lgD0ACJA9fyaAPQACkD9/IoA/AAbANwCQQn9VgEIADMAuAJBCfyGAQgAJwDcAkEl/SZBCfzKASQBJgEIAAsAuAJA7fzqQPX8BgDsAAMA3AJA9f2aAPQAVgD0AA5BAf3OQSX8JgEAAc4BJAAKQTH98gEwAAP8vAA==";
if (MIDIjs) {
MIDIjs.play(dataUrl);
} else {
alert("MIDIjs not loaded");
}