About embed midi files on a webpage

后端 未结 7 987
失恋的感觉
失恋的感觉 2021-02-13 19:18

I am working on a project related to vintage web designs. I would like to embed and autoplay a midi file but:

  1. It doesen\'t work on IOS (I tried with my ipad)
相关标签:
7条回答
  • 2021-02-13 20:06

    I've referenced this question before and fell upon the answer of using the library midijs. However, since that lib now has a bitcoin miner included, I've made a variant without the mining code:

    https://kitchwww.github.io/midi/midi.js

    It can be included and used in exactly the same way:

    <script type='text/javascript' src='https://kitchwww.github.io/midi/midi.js'></script>
    <a href="#" onClick="function(){
    MIDIjs.initAll();
    MIDIjs.play('path/to/yoursong.midi');}">Play My Song</a>
    

    EDIT: updated to include an init function to be called on a User Gesture, as all audio must now be initiated from one.

    0 讨论(0)
提交回复
热议问题