android - how to know when the tonegenerator has stopped playing -
i kneed know when tone generator has stopped playing.
i want play dtmf tone 50 ms , wait 50 play next tone. wanted utilize code.
private void playtones() { new thread(new runnable() { public void run() { for(int i=0 ; i<=19 ; i++){ dtmftone.starttone(savetone.get(i) , 50); seek { thread.sleep(50); } grab (interruptedexception e) { // todo auto-generated grab block e.printstacktrace(); } } } } ).start(); }
the sleep starts before tone has stopped playing. how can check tone has stopped playing? or there @ improve way this?
thx help.
you should utilize method wait(long millis) of tonegenerator instead of thread.sleep(). careful, method not wait sound have stopped, have take duration of beep account:
int beep_duration = 50; int waiting_duration = 50; ... (int = 0; <= 19; i++) { dtmftone.starttone(savetone.get(i), beep_duration); synchronized(dtmftone) { dtmftone.wait(beep_duration + waiting_duration); } ...
and not sure whether want wait 50ms between 2 beeps. if don't, delete "+ waiting_duration"
android thread-sleep tone-generator
No comments:
Post a Comment