Hi ! I am developing an app in order to play sounds. Basicaly, on click button, it plays a sound, simple.
The problem I have now is the latency when touching the button and playing the sound. I tried many things like those ones but nothing work :
- declaring my variables sound out of the click event
- using different type of sound (mp3, ogg, wav)
Here is some alloy code, tell me if you have any idea why it's not working fine, and if it's possible to enable multitouch to play several sounds at the same time, thx !
index.js
var clap = Ti.Media.createSound({url:"/audio/clap.ogg",preload:true}); var bassdrum = Ti.Media.createSound({url:"/audio/bassdrum.ogg",preload:true}); var hithat = Ti.Media.createSound({url:"/audio/hithat.ogg",preload:true}); function playClap(e){ clap.play(); }; function playBassdrum(e){ bassdrum.play(); }; function playHithat(e){ hithat.play(); }; $.index.open();
index.xml
<Alloy> <TabGroup> <Tab title="Tab 1" icon="KS_nav_ui.png"> <Window title="Tab 1"> <Label>I am Window 1</Label> </Window> </Tab> <Tab title="Tab 2" icon="KS_nav_views.png"> <Window title="Tab 2"> <Button id="clap" onClick="playClap">Clap</Button> <Button id="bassdrum" onClick="playBassdrum">Bassdrum</Button> <Button id="hithat" onClick="playHithat">Hithat</Button> </Window> </Tab> </TabGroup> </Alloy>