Playing sound from sound pool in sequence

444 views Asked by At

My app is phone dialer for blind people, and there is a key pad that says the number that gets typed, and I am making a playback button to say all the numbers that get typed.

I am trying to get all numbers to play in sequence after each other but the only problem is that I can't do this with sound pool and media player class is not helping me is there any way to do this with sound pool to make delay between the first number and the second number.

Here's the code I am using to retrieve the user input:

char char1 = text.charAt(0);
int i = soundIdShot2 + char1 - 50;
sp.play(i, 1, 1, 0, 0, 1f);

char char2 = text.charAt(1);
int s = soundIdShot2 + char2 - 50;

sp.play(s, 1, 1, 0, 0, 1f);
2

There are 2 answers

0
pola alper On

I fixed the problem by adding a handler for every sound and making delay between every sound.

0
The_CIA On

Try this:

textToSpeech.speak("thenumberpressed", TextToSpeech.QUEUE_FLUSH, null);                                              
Handler handler = new Handler();   
handler.postDelayed(new Runnable() {
   public void run() {
       //repeat the text to speech line
   } 
}, 10000);

//repeat that 8 more times