本文整理汇总了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