Why android mediaPlayer “onBufferingUpdate” is not work well

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:56:53

问题


 mPlayer.setOnPreparedListener(new OnPreparedListener() {
  @Override
  public void onPrepared(MediaPlayer mp) {
    hideBgAndLoadProcess();
    if (mPlayer.isPlaying()) {
      mPlayer.stop();
    }
    Log.e("TAG", "onPrepared is called");
    mPlayer.start();
  }
});
mPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
  @Override
  public void onBufferingUpdate(MediaPlayer mp, int percent) {
    Log.e("TAG", "percent is :" + percent);
    sbProgress.setSecondaryProgress(percent);
    int currentProgress =
        sbProgress.getMax() * mPlayer.getCurrentPosition() / mPlayer.getDuration();
    Log.e(currentProgress + "% play", percent + "% buffer");
  }
});

myPlayer set the "onBufferingUpdateListener" but it not work well,anybody knows why? when myPlayer is playing ,the "onBufferingUpdate" seems never called because the Log is not print.


回答1:


Try to add the listener before starting the media.



来源:https://stackoverflow.com/questions/17102011/why-android-mediaplayer-onbufferingupdate-is-not-work-well

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!