MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK正如文档所说:
视频是流式传输的,其容器对于渐进式播放无效,即视频的索引(例如 moov atom)不在文件的开头。
MediaPlayer在播放视频时经常会进入error状态,然后提示“can't play this video”对话框,所以你必须通过记住播放时间和重置MediaPlayer引擎后重新播放视频来处理这些错误。
您可以 OnErrorListener
在代码中实现以处理此类错误:
private MediaPlayer.OnErrorListener mOnErrorListener = new MediaPlayer.OnErrorListener() {
public boolean onError(MediaPlayer mp, int what, int extra) {
switch (what) {
case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
Toast.makeText(PlayerActivity.this, "MEDIA_ERROR_SERVER_DIED",
Toast.LENGTH_SHORT).show();
return true;
case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
Toast.makeText(PlayerActivity.this,
"MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK",
Toast.LENGTH_SHORT).show();
break;
case MediaPlayer.MEDIA_ERROR_UNKNOWN:
Toast.makeText(PlayerActivity.this, "MEDIA_ERROR_UNKNOWN",
Toast.LENGTH_SHORT).show();
break;
}
setProgressContainer(true, getString(R.string.msg_handle_error));
int position=mVideoView.getCurrentPosition();
if(position>0){
mCurPosition=position;
}
mVideoView.setVideoPath(mCurrentMediaUrl,position);
return true;
}
};