当前位置:   article > 正文

全志行车记录仪里面FireEyepublic.apk反编译的分析(三)——TTS语音播报_全志 tts

全志 tts

接(一)的分析:FireEyeTTS.init(getResources());


  1. public static void init(Resources paramResources)
  2. {
  3. FIRE_EYE_START = paramResources.getString(2131165307);
  4. RECORD_MODE_VALUE_TWO = paramResources.getString(2131165308);
  5. RECORD_MODE_VALUE_FRONT = paramResources.getString(2131165309);
  6. RECORD_MODE_VALUE_BACK = paramResources.getString(2131165310);
  7. START_RECORDING = paramResources.getString(2131165311);
  8. STOP_RECORDING = paramResources.getString(2131165312);
  9. ………………
  10. }

没有必要多解析,就是初始化需要播报的字符串资源。

  1. private void initTTS()
  2. {
  3. if (mConfig.getTextToSpeech())
  4. FireEyeTTS.StartUseTTS();
  5. else
  6. FireEyeTTS.StopUseTTS();
  7. if (FireEyeTTS.mTTS == null)
  8. FireEyeTTS.mTTS = new TextToSpeech(this, this);
  9. }
TTS的初始化。这个好像是android系统自带的。


在FireEye.java中:

  1. public void onInit(int paramInt)
  2. {
  3. if (paramInt == 0)
  4. {
  5. FireEyeTTS.mTTS.setLanguage(Locale.CHINESE);
  6. Log.d(TAG, "oninit start_record_default = " + start_record_default);
  7. if (start_record_default)
  8. startFireEyeTTS();
  9. }
  10. if (paramInt != -1)
  11. Toast.makeText(this, "Error occurred while initializing Text-To-Speech engine", 1).show();
  12. }
  1. private void startFireEyeTTS()
  2. {
  3. if (mConfig.getAppErrorExit())
  4. {
  5. FireEyeTTS.speakChinese(FireEyeTTS.UN_CAUGHT_EXCEPTION);
  6. mConfig.setAppErrorExit(false);
  7. }
  8. //如果app error就播放 程序异常,退出
  1. if (CarReversingFlag != -1)
  2. FireEyeTTS.speakChinese(FireEyeTTS.CAR_REVERSING); //倒车播报
  3. FireEyeTTS.speakChineseAfterStop(FireEyeTTS.FIRE_EYE_START);
  1. if (mConfig.getMotionDetect())
  2. FireEyeTTS.speakChineseAfterStop(FireEyeTTS.MOTION_DETECT_OPEN); //移动侦测功能打开
  3. if (getIntent().getIntExtra("is_first", 1) != 1)
  4. ShowStorageStatus();//第一次进入的时候要判断内存卡的状态
  5. if ((!mConfig.getAutoRecording()) || ((mConfig.mMotionStatus == 1) && (mConfig.getWorkStatus() == 0)) || (!mExternalStorage))
  6. FireEyeTTS.speakChineseAfterStop(FireEyeTTS.AUTO_RECORDING);//判断是否自动录像
  7. mHandler.sendEmptyMessage(9);
  8. }

转到FireTTS.java:

  1. public static void speakChinese(String paramString)
  2. {
  3. if (!isUsingTTS){
  4. if (mTTS != null){
  5. mTTS.speak(paramString, TextToSpeech.QUEUE_FLUSH, null);
  6. }
  7. }
  8. }
  1. public static void speakChineseAfterStop(String paramString)
  2. {
  3. if (!isUsingTTS){
  4. if (mTTS != null){
  5. mTTS.speak(paramString, TextToSpeech.QUEUE_ADD, null);
  6. }
  7. }
  8. }
每个独立的TTS实例管理语音消息列队请求的优先级和顺序等。当引用 “ TextToSpeech.QUEUE_FLUSH ” 调用Speak()方法时,会中断当前实例正在运行的任务(也可以理解为清除当前语音任务,转而执行新的列队任务)。引用 “ TextToSpeech.QUEUE_ADD ”标签的发音任务将被添加到当前任务列队之后。




声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/255675?site
推荐阅读
相关标签
  

闽ICP备14008679号