将HTML5支持离线缓存音频的访问? [英] Will HTML5 support the access of offline cached audio?

查看:500
本文介绍了将HTML5支持离线缓存音频的访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望使音频基于基于Web的应用程序,将有很多的声音片段。我们要缓存这些文件,这样性能好,而不是依赖于网络速度。可以为离线模式HTML5缓存音频?

We want to make an audio based web based app that will have many sound snippets. We want to cache these files so that performance is good and not dependent on network speed. Can HTML5 cache audio for offline mode?

推荐答案

这当然在我看来,这种的的工作,我找不到说,它不应该工作的任何文件(无论是从W3C或像苹果供应商),但把音频文件作为高速缓存资源清单只是似乎并不在iPad和放大器,Safari浏览器工作; iPhone最少。

It certainly seems to me that this should work, and I can't find any documentation that says it shouldn't work (either from the W3C or from vendors like Apple), but putting audio files as resources in cache manifest just doesn't seem to work with Safari on the iPad & iPhone at least.

听起来发挥很好,当应用程序是在网上(虽然它似乎每次重新加载它们,而不是缓存它们),它不抱怨在离线模式下,当不在那里的资源(这是不立即如果你忘了包括一个JavaScript,CSS,HTML或图像资源)。

Sounds play fine when the app is in online (although it seems to load them anew each time and not cache them) and it doesn't complain about the resources not being there when in offline mode (which is does immediately if you forget to include a JavaScript, CSS, HTML or image resource).

与其抱怨(或负载)的;如果该元素具有控制被替换为一个盒子,上面写着一控无法播放音频文件。另外,如果是没有控制的元素 - 即通过JavaScript访问所有以.play() - 那么它只是简单地不玩(它不引起任何错误,就是没有声响,否则的JavaScript继续执行正常)。

Instead of complaining (or loading); if the element has a control that control is replaced with a box that says "Cannot play audio file.". Alternatively, if it's an element without a control - i.e. accessed via JavaScript all to .play() - then it simply just doesn't play (it doesn't cause any errors, there is just no sound, the JavaScript otherwise continues to execute normally).

我已经和pretty小测试了这个(小于20K)文件,结果是一样的,所以它似乎并没有被相关的大小,只是一个毯子拒绝复制。 <罢>我不知道,如果你能带code声音在一个页面的资源(以base64如EN codeD)的方式,你可以使用图片,但我会以调查选项 - 我怀疑这将是可能的我试图编码音频数据作为数据URI字符串,甚至试图在飞行中产生音频 - 无论做工精细的Safari浏览器在桌面上,但不要在iPhone / iPad的OS工作(至少在版本3.x - 我还没有尝试在iOS 4,但不会为一个星期出,并且预计不会对iPad的几个月,即使他们这样做解决它)

I have tested this with pretty small (<20k) files and the result is the same, so it doesn't seem to be size related, just a blanket refusal to copy. I'm not sure if you can encode sound as a resource in a page (e.g. encoded in base64) the way you can with images, but I'm going to investigate that option - I suspect that would be possible. I tried encoding audio data as data URI strings and even tried generating audio on the fly - both work fine in Safari on the desktop but do not work on the iPhone / iPad OS (at least on version 3.x - I have not tried on iOS 4, but it won't be out for a week, and is not expected for the iPad for a few months, even if they do fix it).

我猜拒绝缓存的声音文件中的iOS是一个执行错误或打算有限的功能。这当然讨厌,进行了大量的用例显示塞。

I would guess the refusal to cache sound files in iOS is an implementation bug or intended limited functionality. It's certainly annoying and a show stopper for a lot of use cases.

我不知道其他HTML5客户端会发生什么,我很想知道(尤其是对的Andr​​iod)。谷歌的音频支持一直没有任何恒星,因此它可以从相同的限制的影响。

I am not sure what happens with other HTML5 clients, I'd be interested to know (in particular on Andriod). Google's support for audio hasn't been stellar either, so it may suffer from the same limitations.

这篇关于将HTML5支持离线缓存音频的访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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