项目里的app里的视频播放是用videoview实现的,最初的播放流程为
<pre style="font-family: Consolas; font-size: 11.3pt; background-color: rgb(255, 255, 255);"><pre name="code" class="html">// 当MediaPlayer准备好后触发该回调
private MediaPlayer.OnPreparedListener mOnPreparedListener = new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
//去把你的 加载中的loading界面去掉
return true;
}
return false;
}
});
}
};
但是某些手机系统中(我遇到有三星的机型), onInfoListener的回调时间会不确定晚了很久。将代码优化为
// 当MediaPlayer准备好后触发该回调 private MediaPlayer.OnPreparedListener mOnPreparedListener = new MediaPlayer.OnPreparedListener() { @Overri