Thanks,
I tried the code, and while tapping different drums, the sound
overlaps, but it does not when tapping the same "drum" over and over
again. Infact, it cuts the previous sound short and starts the sound
over again from the beginning.
Also If you have an animation going (using setInterval) the animation
will briefly halt, causing non-smooth animation.
PhoneGap 0.8.0 used AudioServicesPlaySystemSound to play sounds, and
none of these problems is present in 0.8.0. However the new
Implementation using AVAudioPlayer clearly doesnt work for arcade game
use cases.
Ideally I think you should be able to just do "new Media('sound/
laser.wav').play();" to play sounds. This is what is closest to how
you would do it in a native JavaScript implemenation of <audio> and
Audio function. "new Audio('sound/laser.wav').play();" works perfect
in Firefox and chrome.
/Björn
On Jul 3, 11:45 am, Jesse MacFadyen <
jesse.macfad...@nitobi.com>
wrote:
> function onBodyLoad()
> {
> document.addEventListener("deviceready",onDeviceReady,false);}
>
> var sounds = [];
> /* When this function is called, PhoneGap has been initialized and is ready
> to roll */
> function onDeviceReady()
> {
> var btns = document.getElementById("btns");
> var htmStr = "";
> var template = "<div class='btn'
> ontouchstart='playsound(event,SOUNDID)'>SOUNDID</div>";
> var name = "Basic/Sound";
> for(var n = 0; n < 16; n++)
> {
> sounds.push(new Media(name + n + ".caf"));
> htmStr += template.replace(/SOUNDID/g,n);}
>
> btns.innerHTML = htmStr;
>
> }
>
> function playsound(evt,num)
> {
> sounds[num].play();
>
> }
>
> 2010/7/3 Björn Nilsson <
bni....@gmail.com>
> > > >>>
phonegap+u...@googlegroups.com<
phonegap%2Bunsu...@googlegroups.com>
> >
phonegap+u...@googlegroups.com<
phonegap%2Bunsu...@googlegroups.com>
>
email:'jesse.macfad...@nitobi.com <
email%3A%27jesse.macfad...@nitobi.com>',