}
}
- public void onCompletion(MediaPlayer arg0) {
- String callingApp = mCurrentSpeechItem.mCallingApp;
- ArrayList<String> params = mCurrentSpeechItem.mParams;
- String utteranceId = "";
- if (params != null){
- for (int i = 0; i < params.size() - 1; i = i + 2){
- String param = params.get(i);
- if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
- utteranceId = params.get(i+1);
- }
- }
- }
- if (utteranceId.length() > 0){
- dispatchUtteranceCompletedCallback(utteranceId, callingApp);
- }
- processSpeechQueue();
+ public void onCompletion(MediaPlayer arg0) {\r
+ // mCurrentSpeechItem may become null if it is stopped at the same\r
+ // time it completes.\r
+ SpeechItem currentSpeechItemCopy = mCurrentSpeechItem;\r
+ if (currentSpeechItemCopy != null) {\r
+ String callingApp = currentSpeechItemCopy.mCallingApp;\r
+ ArrayList<String> params = currentSpeechItemCopy.mParams;\r
+ String utteranceId = "";\r
+ if (params != null) {\r
+ for (int i = 0; i < params.size() - 1; i = i + 2) {\r
+ String param = params.get(i);\r
+ if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)) {\r
+ utteranceId = params.get(i + 1);\r
+ }\r
+ }\r
+ }\r
+ if (utteranceId.length() > 0) {\r
+ dispatchUtteranceCompletedCallback(utteranceId, callingApp);\r
+ }\r
+ }\r
+ processSpeechQueue();\r
}
private int playSilence(String callingApp, long duration, int queueMode,