MCPcopy Create free account
hub / github.com/buggins/coolreader / initTTS

Method initTTS

android/src/org/coolreader/CoolReader.java:466–513  ·  view source on GitHub ↗
(final OnTTSCreatedListener listener)

Source from the content-addressed store, hash-verified

464 boolean ttsError;
465
466 public boolean initTTS(final OnTTSCreatedListener listener) {
467 if ( ttsError || !TTS.isFound() ) {
468 if ( !ttsError ) {
469 ttsError = true;
470 showToast("TTS is not available");
471 }
472 return false;
473 }
474 if ( ttsInitialized && tts!=null ) {
475 BackgroundThread.instance().executeGUI(new Runnable() {
476 @Override
477 public void run() {
478 listener.onCreated(tts);
479 }
480 });
481 return true;
482 }
483 if ( ttsInitialized && tts!=null ) {
484 showToast("TTS initialization is already called");
485 return false;
486 }
487 showToast("Initializing TTS");
488 tts = new TTS(this, new TTS.OnInitListener() {
489 @Override
490 public void onInit(int status) {
491 //tts.shutdown();
492 L.i("TTS init status: " + status);
493 if ( status==TTS.SUCCESS ) {
494 ttsInitialized = true;
495 BackgroundThread.instance().executeGUI(new Runnable() {
496 @Override
497 public void run() {
498 listener.onCreated(tts);
499 }
500 });
501 } else {
502 ttsError = true;
503 BackgroundThread.instance().executeGUI(new Runnable() {
504 @Override
505 public void run() {
506 showToast("Cannot initialize TTS");
507 }
508 });
509 }
510 }
511 });
512 return true;
513 }
514
515 private AudioManager am;
516 private int maxVolume;

Callers 1

onCommandMethod · 0.80

Calls 4

isFoundMethod · 0.95
showToastMethod · 0.95
instanceMethod · 0.95
executeGUIMethod · 0.80

Tested by

no test coverage detected