Caching sounds on Mobile Safari

2019-08-31 03:13发布

问题:

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,

回答1:

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