Skip to content

Commit 2077f6e

Browse files
committed
tts: do not re-initialize TTS on DCMD_TTS_PLAY if its already active
1 parent 0a6dd32 commit 2077f6e

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
@@ -2384,13 +2384,15 @@ public void onCommand(final ReaderCommand cmd, final int param, final Runnable o
23842384
showManual();
23852385
break;
23862386
case DCMD_TTS_PLAY: {
2387-
log.i("DCMD_TTS_PLAY: initializing TTS");
2388-
mActivity.initTTS(ttsacc -> BackgroundThread.instance().executeGUI(() -> {
2389-
log.i("TTS created: opening TTS toolbar");
2390-
ttsToolbar = TTSToolbarDlg.showDialog(mActivity, ReaderView.this, ttsacc);
2391-
ttsToolbar.setOnCloseListener(() -> ttsToolbar = null);
2392-
ttsToolbar.setAppSettings(mSettings, null);
2393-
}));
2387+
if(!isTTSActive()){
2388+
log.i("DCMD_TTS_PLAY: initializing TTS");
2389+
mActivity.initTTS(ttsacc -> BackgroundThread.instance().executeGUI(() -> {
2390+
log.i("TTS created: opening TTS toolbar");
2391+
ttsToolbar = TTSToolbarDlg.showDialog(mActivity, ReaderView.this, ttsacc);
2392+
ttsToolbar.setOnCloseListener(() -> ttsToolbar = null);
2393+
ttsToolbar.setAppSettings(mSettings, null);
2394+
}));
2395+
}
23942396
}
23952397
break;
23962398
case DCMD_TOGGLE_DOCUMENT_STYLES:

0 commit comments

Comments
 (0)