简体   繁体   中英

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. 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?

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. (if i play them in safari and on webapp, go to airplane mode, it works)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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