Skip to content

Commit e28d58c

Browse files
committed
tts: do not re-initialize TTS on DCMD_TTS_PLAY if its already active
1 parent e64fb78 commit e28d58c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

android/src/org/coolreader/crengine/ReaderView.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,13 +2414,15 @@ public void onCommand(final ReaderCommand cmd, final int param, final Runnable o
24142414
showManual();
24152415
break;
24162416
case DCMD_TTS_PLAY: {
2417-
log.i("DCMD_TTS_PLAY: initializing TTS");
2418-
mActivity.initTTS(ttsacc -> BackgroundThread.instance().executeGUI(() -> {
2419-
log.i("TTS created: opening TTS toolbar");
2420-
ttsToolbar = TTSToolbarDlg.showDialog(mActivity, ReaderView.this, ttsacc);
2421-
ttsToolbar.setOnCloseListener(() -> ttsToolbar = null);
2422-
ttsToolbar.setAppSettings(mSettings, null);
2423-
}));
2417+
if(!isTTSActive()){
2418+
log.i("DCMD_TTS_PLAY: initializing TTS");
2419+
mActivity.initTTS(ttsacc -> BackgroundThread.instance().executeGUI(() -> {
2420+
log.i("TTS created: opening TTS toolbar");
2421+
ttsToolbar = TTSToolbarDlg.showDialog(mActivity, ReaderView.this, ttsacc);
2422+
ttsToolbar.setOnCloseListener(() -> ttsToolbar = null);
2423+
ttsToolbar.setAppSettings(mSettings, null);
2424+
}));
2425+
}
24242426
}
24252427
break;
24262428
case DCMD_TOGGLE_DOCUMENT_STYLES:

0 commit comments

Comments
 (0)