I have developed my first ever Laravel web application, which you can find at: www.sharpguitartraining.com, and that uses .mp3 files from gleitz/midi-js-soundfonts CDN to play guitar notes one at a time, and it works fine on desktop computers, but is totally silent in both iOS and Android devices.
This is how I play the sounds on the website:
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/inc/shim/Base64.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/inc/shim/Base64binary.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/inc/shim/WebAudioAPI.js"></script>
<!-- midi.js package -->
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/midi/audioDetect.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/midi/gm.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/midi/loader.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/midi/plugin.audiotag.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/midi/plugin.webaudio.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/midi/plugin.webmidi.js"></script>
<!-- utils -->
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/util/dom_request_xhr.js"></script>
<script src="https://cdn.rawgit.com/mudcube/MIDI.js/a8a84257/js/util/dom_request_script.js"></script>
function playNote_CDN(note, sonido_id, velocity, delay, mensaje) {
var instrument_name = sonido_id ? $('#sonidos')[0].options[sonido_id].text : $('#sonidos')[0].selectedOptions[0].text;
var delay = delay ? delay : 0; // play one note every quarter second
var velocity = velocity ? velocity : 127; // how hard the note hits
var note = note ? note - 1 : 61;
var volumen = $('#volumen').val() / 100 * 127;
MIDI.loadPlugin({
soundfontUrl: "http://gleitz.github.io/midi-js-soundfonts/FluidR3_GM/",
instrument: instrument_name,
onprogress: function(state, progress) {
},
onsuccess: function () {
if (mensaje) {
muestraMensaje("Instrumento " + instrument_name + " cargado.", 3);
}
MIDI.programChange(0, MIDI.GM.byName[instrument_name].number);
MIDI.setVolume(0, volumen);
MIDI.noteOn(0, note, velocity, delay);
MIDI.noteOff(0, note, delay + 1);
}
});
}
I have no clue how to proceed, so any help is greatly appreciated.
Thank you!