我已经开发了我的第一个Laravel web应用程序,你可以在www.sharpguitartraining.com上找到它,它使用gleitz/midi-js-soundfonts CDN中的.mp3文件一次演奏一个吉他音符,它在台式电脑上运行良好,但在iOS和安卓设备上都是完全静默的。
这是我在网站上播放声音的方式:
<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);
}
});
}我不知道如何继续,所以非常感谢任何帮助。
谢谢!
发布于 2019-07-10 09:37:41
我没有得到答案,但我找到了问题所在。我调用了gleitz/midi-js-soundfonts,它的CDN是http://协议,来自我的站点,是https://协议,所以Chrome阻止了调用,因为显然你不允许从安全的https站点调用不安全的http CDN。这是在Chrome的开发控制台上的preety显式。希望这对其他人有帮助。干杯!
https://stackoverflow.com/questions/56800404
复制相似问题