Developing an HTML 5 application on new iPad's Mobile Safari iOS 5 that displays a user prompt when a "dispatch" is received. To bring attention to the user, we have a sound that plays like this when a alert function is called:
snd.src = snd.src;
snd.play();
Unfortunately, Apple changed the methodology for playing sounds. Does anyone know if there are updates in iOS 5 that fixes this?
*Did a lot of research and already aware that the old "hack" in iOS 3 no longer works.
Tap the song that's playing at the bottom of your screen. In the lower-right corner of your screen, tap Playing Next. . Scroll down to Autoplay.
The sounds require user input in iOS5. You can initialize the sound with an "invisible" button that disappears after one press at the initialization of your app. Once triggered, you should be able to call snd.play()
programatically. It's kind of a cheat, but hopefully it helps!
Javascript:
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
document.write('<a id="init" ontouchstart="javascript:sndInit();"></a>');
function sndInit(){
snd.play();
snd.pause();
document.getElementById('init').style.display = 'none';
}
}
CSS:
<style>
#init {
position: absolute;
margin-right: 0px;
margin-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
z-index: 1000;
}
</style>
Also, Remy Sharp has some tips on working with audio sprites HERE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With