简体   繁体   English

在Mobile Safari上缓存声音

[英]Caching sounds on Mobile Safari

I have to play very short sounds on UI events (pressing a button, showing a popup) in my iOS web-app. 我必须在iOS网络应用程序中的UI事件(按按钮,显示弹出窗口)上播放非常短的声音。 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();
}

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? 是否可以强迫iPhone以某种方式缓存声音,而不是每次都不重新加载声音?

Regards, 问候,

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. 我正在使用html5清单文件来缓存其正常工作的内容,但是,声音似乎只在我在野生动物园中播放了至少一次之后才进行缓存。 (if i play them in safari and on webapp, go to airplane mode, it works) (如果我在野生动物园和Webapp上播放它们,请进入飞行模式,它可以正常工作)

you might be interessted in this thread Offline iOS web app: loads my manifest, but doesn't work offline 您可能对此线程感兴趣。 离线iOS网络应用:加载我的清单,但不能离线工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM