如何通过 NPAPI 插件读取音乐文件并使用
我正在考虑从硬盘读取 MP3 文件并在浏览器中播放它。我知道一种方法 - 从<获取文件对象列表code> 标签,然后获取其对象 URL 并将其分配给 的
src
。然而,这种技术也有一些缺点(其中之一,必须在每次页面刷新时重复)。
因此,我正在探索是否可以使用 NPAPI 插件从 HDD 读取音乐文件,然后以某种方式将其提供给 元素。但是,我不知道如何将图块的二进制内容转换为 javascript 可以使用的 File 对象。有什么建议吗?
I am playing with the idea of reading an MP3 file from the hard drive and playing it in the browser. I know one way of doing it - get list of File objects from <input>
tag, then get their object URL and assign it to src
of <audio>
. However there are some drawbacks of this technique (for one, it has to be repeated on every page refresh).
Therefore I am exploring if I can use an NPAPI plugin to read the music file from the HDD and then give it to <audio>
element somehow. However, I can't figure out how to convert the binary contents of the tile into a File object that javascript can use. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一选择是使用 data: url。我不确定音频标签是否支持这些,但 img 标签肯定支持它们。
顺便说一句,您知道 NPAPI 插件必须先通过对象标记注入页面,然后才能执行任何操作,对吧?确保您知道扩展和插件之间的区别,因为您所说的听起来更像是扩展问题。
另请查看 FireBreath;如果您决定使用 NPAPI 插件,那将大大简化您的生活。
The only option I can think of would be to use a data: url. I don't know for sure if these are supported in audio tags or not, but they are definitely supported in img tags.
BTW, you are aware that a NPAPI plugin has to be injected into the page in an object tag before it does anything, right? Make sure you know the difference between an extension and a plugin, because what you're talking about sounds more like an extension problem.
Also take a look at FireBreath; if you do decide to use a NPAPI plugin, that'll simplify your life a lot.