赞
踩
接(一)的分析:FireEyeTTS.init(getResources());
- public static void init(Resources paramResources)
- {
- FIRE_EYE_START = paramResources.getString(2131165307);
- RECORD_MODE_VALUE_TWO = paramResources.getString(2131165308);
- RECORD_MODE_VALUE_FRONT = paramResources.getString(2131165309);
- RECORD_MODE_VALUE_BACK = paramResources.getString(2131165310);
- START_RECORDING = paramResources.getString(2131165311);
- STOP_RECORDING = paramResources.getString(2131165312);
- ………………
- }
- private void initTTS()
- {
- if (mConfig.getTextToSpeech())
- FireEyeTTS.StartUseTTS();
- else
- FireEyeTTS.StopUseTTS();
-
- if (FireEyeTTS.mTTS == null)
- FireEyeTTS.mTTS = new TextToSpeech(this, this);
-
- }
TTS的初始化。这个好像是android系统自带的。
在FireEye.java中:
- public void onInit(int paramInt)
- {
- if (paramInt == 0)
- {
- FireEyeTTS.mTTS.setLanguage(Locale.CHINESE);
- Log.d(TAG, "oninit start_record_default = " + start_record_default);
- if (start_record_default)
- startFireEyeTTS();
- }
-
- if (paramInt != -1)
- Toast.makeText(this, "Error occurred while initializing Text-To-Speech engine", 1).show();
-
- }
- private void startFireEyeTTS()
- {
- if (mConfig.getAppErrorExit())
- {
- FireEyeTTS.speakChinese(FireEyeTTS.UN_CAUGHT_EXCEPTION);
- mConfig.setAppErrorExit(false);
- }
- //如果app error就播放 程序异常,退出
- if (CarReversingFlag != -1)
- FireEyeTTS.speakChinese(FireEyeTTS.CAR_REVERSING); //倒车播报
-
- FireEyeTTS.speakChineseAfterStop(FireEyeTTS.FIRE_EYE_START);
- if (mConfig.getMotionDetect())
- FireEyeTTS.speakChineseAfterStop(FireEyeTTS.MOTION_DETECT_OPEN); //移动侦测功能打开
-
- if (getIntent().getIntExtra("is_first", 1) != 1)
- ShowStorageStatus();//第一次进入的时候要判断内存卡的状态
-
- if ((!mConfig.getAutoRecording()) || ((mConfig.mMotionStatus == 1) && (mConfig.getWorkStatus() == 0)) || (!mExternalStorage))
- FireEyeTTS.speakChineseAfterStop(FireEyeTTS.AUTO_RECORDING);//判断是否自动录像
- mHandler.sendEmptyMessage(9);
-
- }
转到FireTTS.java:
- public static void speakChinese(String paramString)
- {
- if (!isUsingTTS){
- if (mTTS != null){
- mTTS.speak(paramString, TextToSpeech.QUEUE_FLUSH, null);
- }
- }
- }
- public static void speakChineseAfterStop(String paramString)
- {
- if (!isUsingTTS){
- if (mTTS != null){
- mTTS.speak(paramString, TextToSpeech.QUEUE_ADD, null);
- }
- }
- }
每个独立的TTS实例管理语音消息列队请求的优先级和顺序等。当引用 “
TextToSpeech.QUEUE_FLUSH
” 调用Speak()方法时,会中断当前实例正在运行的任务(也可以理解为清除当前语音任务,转而执行新的列队任务)。引用 “
TextToSpeech.QUEUE_ADD
”标签的发音任务将被添加到当前任务列队之后。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。