/** Stops the playing sounds. */ public static void stopSounds() { if (sMediaPlayer != null) { sMediaPlayer.stop(); releaseSound(); } ReadText.stopTts(); }
public static void speak(String text, String loc) { int result = mTts.setLanguage(new Locale(loc)); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Toast.makeText( mReviewer.get(), mReviewer.get().getString(R.string.no_tts_available_message) + " (" + loc + ")", Toast.LENGTH_LONG) .show(); Timber.e("Error loading locale " + loc); } else { if (mTts.isSpeaking()) { Timber.d("tts engine appears to be busy... clearing queue"); stopTts(); // sTextQueue.add(new String[] { text, loc }); } Timber.d("tts text '%s' to be played for locale (%s)", text, loc); mTts.speak(mTextToSpeak, TextToSpeech.QUEUE_FLUSH, mTtsParams); } }