1

I'm using a TTS engine, and i want to disable the buttons until the tts message has finished, so the user can't select an option on the screen until the tts message has been listened completely.

I've been trying using

while (tts.isSpeaking())
{
    button.setclickable(false);
}
button.setclickable(true);

but it's not working.

I guess that is because tts.isSpeaking doesn't work as i expected.

Charles
  • 50,943
  • 13
  • 104
  • 142
user897013
  • 165
  • 1
  • 3
  • 9
  • 1
    What is not working? Be more specific. If you get any errors, add your LogCat output. – Lukas Knuth Sep 27 '11 at 09:51
  • Let's supose that tts has to play the message, "If you want to play, press the green button, or if you want to exit, press the red button". The user should wait until the end of the message to know which button he should press. When i use my code, if the user touches the green button before the message has been totally played, the activity will change to another one, but the message will be still playing, and that's is not very elegant. Also, i don't think i can debug that. – user897013 Sep 27 '11 at 11:46

1 Answers1

2

check the Utterance concept with this TTS using this you can implement your task check here

http://developer.android.com/resources/articles/tts.html

http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setOnUtteranceCompletedListener%28android.speech.tts.TextToSpeech.OnUtteranceCompletedListener%29

Pratik
  • 30,639
  • 18
  • 84
  • 159
  • Thank you. I will try that and i'll let you know. – user897013 Sep 27 '11 at 11:46
  • I could make it work with onUtteranceCompleted, but i had to visit this answer [link]( http://stackoverflow.com/questions/6645893/onutterancecompleted-does-not-get-called) because the listener wasn't get called. – user897013 Oct 02 '11 at 11:35