private void doFinalInitialization() { if (null == myTTS.getLanguage()) { setActionsEnabled(false); showErrorMessage(getText(R.string.no_tts_language), true); return; } myTTS.setOnUtteranceCompletedListener(this); myTTS.addEarcon(CONTENTS_EARCON, "org.benetech.android", R.raw.sound_toc); myTTS.addEarcon(MENU_EARCON, "org.benetech.android", R.raw.sound_main_menu); myTTS.addEarcon(FORWARD_EARCON, "org.benetech.android", R.raw.sound_forward); myTTS.addEarcon(BACK_EARCON, "org.benetech.android", R.raw.sound_back); myTTS.addEarcon(START_READING_EARCON, "org.benetech.android", R.raw.sound_start_reading); setCurrentLocation(); myTTS.playEarcon(START_READING_EARCON, TextToSpeech.QUEUE_ADD, null); if (accessibilityManager.isEnabled()) { speakString(myApi.getBookTitle(), 0); } else { setTitle(myApi.getBookTitle()); } setActionsEnabled(true); speakParagraph(getNextParagraph()); }
/** * Plays an earcon given its id. * * @param earconId The id of the earcon to be played. */ private void playEarcon(int earconId) { String earconName = mEarconNames.get(earconId); if (earconName == null) { // we do not know the sound id, hence we need to load the sound int resourceId = sSoundsResourceIds.get(earconId); earconName = "[" + earconId + "]"; mTts.addEarcon(earconName, getPackageName(), resourceId); mEarconNames.put(earconId, earconName); } mTts.playEarcon(earconName, QUEUING_MODE_INTERRUPT, null); }