本文整理匯總了Java中android.speech.tts.TextToSpeech.QUEUE_FLUSH屬性的典型用法代碼示例。如果您正苦於以下問題:Java TextToSpeech.QUEUE_FLUSH屬性的具體用法?Java TextToSpeech.QUEUE_FLUSH怎麽用?Java TextToSpeech.QUEUE_FLUSH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.speech.tts.TextToSpeech
的用法示例。
在下文中一共展示了TextToSpeech.QUEUE_FLUSH屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: speak
@ReactMethod
public void speak(String utterance, String queueMode, Promise promise) {
if(notReady(promise)) return;
if(IS_DUCKING) {
int amResult = audioManager.requestAudioFocus(afChangeListener,
AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
if(amResult != AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
promise.reject("error", "Android AudioManager error, failed to request audio focus");
}
String utteranceId = Integer.toString(utterance.hashCode());
int mode = TextToSpeech.QUEUE_ADD;
if(queueMode.equals("ADD"))
mode = TextToSpeech.QUEUE_ADD;
else if(queueMode.equals("FLUSH"))
mode = TextToSpeech.QUEUE_FLUSH;
int speakResult = speak(utterance, mode, utteranceId);
if(speakResult == TextToSpeech.SUCCESS) {
promise.resolve(utteranceId);
} else {
promise.reject("error", "Unable to play. Error at speak(utterance, queueMode)");
}
}
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:28,代碼來源:RNAndroidTextToSpeechModule.java