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 设置了“onBufferingUpdateListener”,但效果不佳,有人知道为什么吗?当 myPlayer 播放时,“onBufferingUpdate”似乎从未被调用,因为日志未打印。