private void showContents() {
   justPaused = true;
   stopTalking();
   myTTS.playEarcon(CONTENTS_EARCON, TextToSpeech.QUEUE_FLUSH, null);
   Intent tocIntent = new Intent(this, TOCActivity.class);
   startActivityForResult(tocIntent, PLAY_AFTER_TOC);
 }
  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());
  }
 private void showMainMenu() {
   stopTalking();
   justPaused = true;
   myTTS.playEarcon(MENU_EARCON, TextToSpeech.QUEUE_ADD, null);
   resumePlaying = true;
   Intent intent = new Intent(this, AccessibleMainMenuActivity.class);
   startActivityForResult(intent, PLAY_AFTER_TOC);
 }
 private void goForward() {
   stopTalking();
   myTTS.playEarcon(FORWARD_EARCON, TextToSpeech.QUEUE_ADD, null);
   if (myParagraphIndex < myParagraphsNumber) {
     ++myParagraphIndex;
     speakParagraph(getNextParagraph());
   }
 }
Example #5
0
  /**
   * 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);
  }
  @Override
  protected void onResume() {
    super.onResume();
    findViewById(R.id.speak_menu_pause).requestFocus();

    if (!abortedTOCReturn) {
      setCurrentLocation();
    }
    abortedTOCReturn = false;

    if (resumePlaying || justPaused) {
      resumePlaying = false;
      myTTS.playEarcon(START_READING_EARCON, TextToSpeech.QUEUE_ADD, null);
      speakParagraph(getNextParagraph());
    }
  }
 private void goBackward() {
   stopTalking();
   myTTS.playEarcon(BACK_EARCON, TextToSpeech.QUEUE_ADD, null);
   gotoPreviousParagraph();
   speakParagraph(getNextParagraph());
 }