将HTML5音频对象拆分为多个音频对象 [英] Splitting an HTML5 Audio Object into Multiple Audio Objects

查看:100
本文介绍了将HTML5音频对象拆分为多个音频对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已将多个音频文件合并为一个音频文件(因此只使用一个HTTP请求),我可以使用JavaScript将它们拆分为客户端的几个HTML5音频对象,如果是这样,怎么做?另外,如果有可能,这会比多个请求有任何优势吗?

Assuming that I've merged several audio files into a single audio file (thus using only a single HTTP request), can I split them up into several HTML5 audio objects on the client side with JavaScript and, if so, how? Also, if it is possible, would this have any advantages over multiple requests?

推荐答案

到目前为止,这就是我的意思发现... HTML5音频不是为此而构建的。 Safari也出现了许多其他问题(请参阅此问题和它的答案)然而,Web Audio API看起来似乎可以解决问题。虽然还没有完全支持,但有 github上的polyfill 对API的支持正在迅速成为现实。已经制作了利用此API的游戏(参见 Field Runners

So far, this is what I've found out...HTML5 Audio isn't built for that. Numerous other problems arise with Safari too (see this question and its answers) However, the Web Audio API seems like it might do the trick. While it's not fully supported yet, there are polyfills on github and support for the API is quickly becoming a reality. Games have already been made that utilize this API (see Field Runners)

我还找到了一些关于如何使用它的好教程 - 主要是在 creativejs html5rocks

I've also found some nice tutorials on how to use it - primarily at creativejs and html5rocks.

最后,我发现正在使用的API的一个很好的例子。 (但是示例中的声音非常安静。您可能需要调高音量才能听到它)

Lastly, I've found an excellent example of the API in use. (The sound in the example is very quiet, though. You might need to turn up your volume to hear it)

这篇关于将HTML5音频对象拆分为多个音频对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆