Mediaplayer progress update to seekbar not smooth?

前端 未结 6 2066
情话喂你
情话喂你 2021-02-01 07:00

I am working on an app with recorder and player. I am using mediaplayer to play the recorded .wav file and meantime I want to update to a seekbar. Everything is working fine But

6条回答
  •  渐次进展
    2021-02-01 07:38

    player.prepare(); // or start()
    
    ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
    service.scheduleWithFixedDelay(new Runnable()
    {
      @Override
      public void run()
      {
        progressBar.setProgress(player.getCurrentPosition());
      }
    }, 1, 1, TimeUnit.MICROSECONDS);
    

提交回复
热议问题