首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在移动设备上播放CDN Soundfonts

在移动设备上播放CDN Soundfonts
EN

Stack Overflow用户
提问于 2019-06-28 10:57:27
回答 1查看 78关注 0票数 0

我已经开发了我的第一个Laravel web应用程序,你可以在www.sharpguitartraining.com上找到它,它使用gleitz/midi-js-soundfonts CDN中的.mp3文件一次演奏一个吉他音符,它在台式电脑上运行良好,但在iOS和安卓设备上都是完全静默的。

这是我在网站上播放声音的方式:

代码语言:javascript
复制
    <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);
                }
            }); 
    }

我不知道如何继续,所以非常感谢任何帮助。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-07-10 09:37:41

我没有得到答案,但我找到了问题所在。我调用了gleitz/midi-js-soundfonts,它的CDN是http://协议,来自我的站点,是https://协议,所以Chrome阻止了调用,因为显然你不允许从安全的https站点调用不安全的http CDN。这是在Chrome的开发控制台上的preety显式。希望这对其他人有帮助。干杯!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56800404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档