@@ -331,10 +331,9 @@ private void stopProgressTimer() {
331331 }
332332
333333 private void startProgressTimer () {
334- String timeString = new SimpleDateFormat ("mm:ss" ).format (engine .getAudioMixingDuration ());
335- progressText .setText (timeString );
336- final int result = (int ) ((float ) engine .getAudioMixingCurrentPosition () / (float ) engine .getAudioMixingDuration () * 100 );
337- mixingProgressBar .setProgress (Long .valueOf (result ).intValue ());
334+ engine .getAudioFileInfo (Constant .URL_PLAY_AUDIO_FILES );
335+ int position = engine .getAudioMixingCurrentPosition ();
336+ handler .post (()->mixingProgressBar .setProgress (position ));
338337 handler .postDelayed (this ::startProgressTimer , 500 );
339338 }
340339 /**
@@ -513,8 +512,17 @@ public void onUserOffline(int uid, int reason)
513512
514513 @ Override
515514 public void onRequestAudioFileInfo (AudioFileInfo info , int error ) {
516- Log .d (TAG , "onRequestAudioFileInfo: " +info .durationMs );
517- handler .post (()-> mixingProgressBar .setMax (info .durationMs ));
515+ if (info .durationMs > 0 && progressText .getText ().equals ("00:00" )) {
516+ Log .d (TAG , "onRequestAudioFileInfo: " +info .durationMs );
517+ handler .post (new Runnable () {
518+ @ Override
519+ public void run () {
520+ mixingProgressBar .setMax (info .durationMs );
521+ String timeString = new SimpleDateFormat ("mm:ss" ).format (info .durationMs );
522+ progressText .setText (timeString );
523+ }
524+ });
525+ }
518526 }
519527 };
520528
@@ -541,9 +549,6 @@ else if(seekBar.getId() == R.id.mixingVolBar){
541549 * @param volume: Audio mixing volume. The value ranges between 0 and 100 (default).
542550 */
543551 engine .adjustAudioMixingVolume (progress );
544- }else if (seekBar .getId () == R .id .mixingProgress ){
545- String durationText = io .agora .api .example .utils .TextUtils .durationFormat ((long ) progress );
546- progressText .setText (durationText );
547552 }else if (seekBar .getId () == R .id .slider_speed_fg_audio_file ){
548553 updateSpeedTitle ();
549554 }
0 commit comments