问题
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