pola alper
pola alper

Reputation: 194

Playing sound from sound pool in sequence

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);

Upvotes: 2

Views: 442

Answers (2)

The_CIA
The_CIA

Reputation: 117

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

Upvotes: 0

pola alper
pola alper

Reputation: 194

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

Upvotes: 0

Related Questions