在Mobile Safari上缓存声音 [英] Caching sounds on Mobile Safari

查看:97
本文介绍了在Mobile Safari上缓存声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在iOS网络应用程序中的UI事件(按按钮,显示弹出窗口)中播放非常短的声音.我是通过以下方式完成的:

I have to play very short sounds on UI events (pressing a button, showing a popup) in my iOS web-app. I do it the following way:

// Standard HTML5 implementation of PlaySound.
function Html5PlaySound(sound)
{
    var player = document.getElementById('soundPlayer');
    player.pause();
    player.setAttribute('src', 'sound/' + sound + '.mp3');
    player.play();
}

不幸的是,每次都在重新加载它(我在标题栏中看到等待圈").是否可以强迫iPhone以某种方式缓存声音,而不是每次都不重新加载声音?

Unfortunately, it's being reloaded every time (I see 'waiting circle' in the title bar). Is it possible to force somehow iPhone to cache the sounds and not reload them every time?

此致

推荐答案

我正在使用html5清单文件来缓存内容 它的工作正常,但似乎声音只在我在野生动物园中播放了至少一次之后才被​​缓存. (如果我在野生动物园和Webapp上播放它们,请进入飞行模式,这是可行的)

i am using html5 manifest for caching stuff its working fine, however it seems the sounds only cache after i play them at least once in safari. (if i play them in safari and on webapp, go to airplane mode, it works)

您可能对此线程感兴趣 离线iOS网络应用:加载我的清单,但是不能离线工作

you might be interessted in this thread Offline iOS web app: loads my manifest, but doesn't work offline

这篇关于在Mobile Safari上缓存声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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