关于在网页上嵌入 MIDI 文件
我正在从事一个与复古网页设计相关的项目。我想嵌入并自动播放一个 midi 文件,但是:
- 它在 IOS 上不起作用(我用我的 ipad 尝试过)
- 在 Firefox 上,有时无法播放曲子,我不知道为什么。
MIDI 播放器是否依赖于浏览器或插件? 我可以找到一种通用的替代方法来演奏我的曲子吗?
我以这种方式使用 标签:
<embed src="tune.mid" hidden="true" autostart="true" autoplay="true">
I am working on a project related to vintage web designs. I would like to embed and autoplay a midi file but:
- It doesen't work on IOS (I tried with my ipad)
- On Firefox, sometimes the tune is not played, I don't know why.
Does the midi player depends on the browser or a plugin?
Can I find a univeral alternative to play my tune?
I am using the <embed>
tag this way:
<embed src="tune.mid" hidden="true" autostart="true" autoplay="true">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我之前引用过这个问题,并找到了使用库 midijs 的答案。
但是,由于该库现在包含一个比特币挖矿程序,因此我制作了一个没有挖矿代码的变体:
https://kitchwww.github.io/midi/midi.js
它可以以完全相同的方式包含和使用:
编辑:更新为包含要在用户手势上调用的 init 函数,因为所有音频现在必须是从一开始。
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:
EDIT: updated to include an init function to be called on a User Gesture, as all audio must now be initiated from one.
是的,embed 标签是为插件保留的,Mobile Safari 不支持该插件。
看一下 HTML5 音频 标记,它大多数浏览器都支持。
但请不要在网页上播放音乐……这很烦人 - 大多数人要么听音乐,要么关闭扬声器,要么在办公室。
Yes, the embed tag is reserved for plugins, which Mobile Safari doesn't support.
Take a look at HTML5 audio tag, which is supported by most browsers.
But please don't play music on a webpage... it's annoying - most either listens to music, have the speakers turned off, or are at the office.
你的 HTML 没问题。问题是一些较低级别的浏览器已经失去了播放 midi 文件的能力。他们必须安装一个附加组件。 Real Player曾经是一个很好的解决方案,但现在他们正在推动云订阅。周围还有很多其他 MIDI 播放器,但用户必须安装一个。
Your HTML is OK. The problem is that some lower class browsers have lost the ability to play midi files. They have to install an add on. Real Player used to be a good solution, but now they are pushing a cloud subscription. There are plenty of other midi players around, but the users have to install one.
随着时间的推移,浏览器不再支持本地播放 MIDI 文件。您可能想尝试 MIDI.js,一个基于 JavaScript 的跨浏览器库。
将 MIDI.js 脚本添加到您的网页:
然后添加一个链接以开始播放:
看一下 http://www .midijs.net 了解详情。
Browsers dropped support for playing MIDI files natively over time. You might want to try MIDI.js, a JavaScript based cross browser library.
Add the MIDI.js script to your webpage:
And then add a link to start playing:
Take a look at http://www.midijs.net for details.
对于 mid 和 kar 文件,我建议使用 vanBasco midi 播放器作为默认播放器。请参阅 http://midkar.com/blues/blues_01.html 上的源代码
嵌入;
嵌入src =“musicfile.mid”宽度= 144高度= 60自动启动= true重复= false循环= false
(将“musicfile.mid”替换为您的 midi 文件的名称)
For mid, and kar files, I suggest using vanBasco midi player as your default player. See the source on http://midkar.com/blues/blues_01.html
To Embed;
embed src="musicfile.mid" width=144 height=60 autostart=true repeat=false loop=false
(replace the "musicfile.mid" with the name of your midi file)
https://kitchwww.github.io/midi/midi.js 不工作,因为缺少笔记(根据我的研究)
http://www.midijs.net 仍然有比特币矿工
我发现唯一适用于 midi 文件的是 https://github.com/cifkao/ html-midi-player,它有 midi 播放器,您可以在其中播放 midis,它还有一个用于设置时间的栏和一个 midi 可视化工具
https://kitchwww.github.io/midi/midi.js Doesn't work because there is missing notes (From what I researched)
http://www.midijs.net Still has a bitcoin miner
The only thing i found that is working for midi files is https://github.com/cifkao/html-midi-player, it has the midi player where you can play midis and it, a bar to set the time and a midi visualizer
使用 HTML5 音频标签。但就像我前面的人说的那样……请重新考虑您页面上的音乐。
Use the HTML5 Audio tag. But like The guy before me said.... please reconsider music on your page.
好吧,现在是 2017 年 8 月 13 日,您是否知道在网页上嵌入 bg midi 仍然是一个谜。
事实上,我很确定它甚至不能再完成(除了 IE 的 bgsound src,它对我来说仍然工作得很好)。
但对于 Firefox 和 Chrome,jofeu 提供的解决方案是一个很好的解决方法。
我只希望有一种嵌入方式,这样 MIDI 就可以在页面加载时开始播放,而无需单击任何内容。我想那些日子已经一去不复返了。
Well, here it is Aug 13, 2017 and don't you know embedding a bg midi on a web page is still a mystery.
In fact I'm pretty certain it can't even be done anymore (except IE's bgsound src, which still works fine for me).
But as for Firefox and Chrome, the solution provided by jofeu is a great work-around.
I only wish there was a way to embed so the midi just starts playing on page load, without having to click anything. I guess those days are gone.