@@ -75,6 +75,7 @@ public class TTSToolbarDlg implements Settings {
7575 private final ImageButton forwardButton ;
7676 private final ImageButton stopButton ;
7777 private final ImageButton optionsButton ;
78+ private final TextView mAudioProgressTextView ;
7879 private final TextView mVolumeTextView ;
7980 private final TextView mSpeedTextView ;
8081 private final SeekBar mSbSpeed ;
@@ -195,6 +196,30 @@ private SentenceInfo fetchSelectedSentenceInfo() {
195196 return null ;
196197 }
197198
199+ private String formatDurationHHHMMSS (double duration ) {
200+ return String .format (Locale .getDefault (), "%3d:%02d:%02d" ,
201+ ((int ) duration ) / 60 / 60 ,
202+ ((int ) duration ) / 60 % 60 ,
203+ ((int ) duration ) % 60 );
204+ }
205+
206+ private void setAudioBookProgressDisplay (SentenceInfo sentenceInfo ) {
207+ if (sentenceInfo == null ){
208+ mAudioProgressTextView .setVisibility (View .GONE );
209+ mAudioProgressTextView .setText ("" );
210+
211+ mSbSpeed .setVisibility (View .VISIBLE );
212+ }else {
213+ mAudioProgressTextView .setVisibility (View .VISIBLE );
214+ mAudioProgressTextView .setText (String .format (Locale .getDefault (),
215+ "%s / %s" ,
216+ formatDurationHHHMMSS (sentenceInfo .startTimeInBook ),
217+ formatDurationHHHMMSS (sentenceInfo .totalBookDuration )));
218+
219+ mSbSpeed .setVisibility (View .GONE );
220+ }
221+ }
222+
198223 /**
199224 * Select next or previous sentence. ONLY the selection changes and the specified callback is called!
200225 * Not affected to speech synthesis process.
@@ -211,11 +236,14 @@ public void onNewSelection(Selection selection) {
211236 mCurrentSelection = selection ;
212237 if (allowUseAudiobook ){
213238 SentenceInfo sentenceInfo = fetchSelectedSentenceInfo ();
239+ setAudioBookProgressDisplay (sentenceInfo );
214240 if (sentenceInfo != null && sentenceInfo .audioFile != null ){
215241 mTTSControl .bind (ttsbinder -> {
216242 ttsbinder .setAudioFile (sentenceInfo .audioFile , sentenceInfo .startTime );
217243 });
218244 }
245+ }else {
246+ setAudioBookProgressDisplay (null );
219247 }
220248 if (null != callback )
221249 callback .onNewSelection (mCurrentSelection );
@@ -561,6 +589,11 @@ public TTSToolbarDlg(CoolReader coolReader, ReaderView readerView, TTSControlSer
561589 }));
562590 stopButton .setOnClickListener (v -> stopAndClose ());
563591
592+
593+ // setup audiobook speed && volume seek bars
594+ mAudioProgressTextView = panel .findViewById (R .id .tts_lbl_audio_progress );
595+ mAudioProgressTextView .setVisibility (View .GONE );
596+
564597 // setup speed && volume seek bars
565598 mVolumeTextView = panel .findViewById (R .id .tts_lbl_volume );
566599 mSpeedTextView = panel .findViewById (R .id .tts_lbl_speed );
0 commit comments