I have a small application that basically sets up a timer and plays sets of 2 sounds one by one .
I tried 2 timers because I wanted both sounds to start exactly at the same time every time. I gave a 500ms application to set both timers before they start
Calendar cal = Calendar.getInstance();
Date start = new Date(cal.getTime().getTime() + 500);
timerTask1 = new TimerTask() {
@Override
public void run() {
soundManager.playSound(1);
}
};
timer1 = new Timer();
timer1.schedule(timerTask1, start, 550);
timerTask2 = new TimerTask() {
@Override
public void run() {
soundManager.playSound(2);
}
};
timer2 = new Timer();
timer2.schedule(timerTask2, start, 550);
}
soundManager is a SoundManager object based on this guide . The only change I made was to decrease the number of available streams from 20 to 2, as I only play 2 sounds at a time.
. Motorola RAZR, . , , . . ?
OGG
EDIT:
. 2 . . 500 .
- aproach TimerTask - . 300 , , (2 ) 497 , , .
- 2- aproach AsyncTask - 475 500 , , TimerTask,
aproach .