我正在播放一个来自网址的视频,但其工作正常但有时候
日志提供
MediaPlayer error (1, -1004)
MediaPlayer Error (1, -1004)
有时候它会启动一个对话框,说明媒体播放器无法播放此视频 对于相同的URL | 所以为什么会发生这种情况,这个错误的含义是什么以及如何解决?
这是我的代码
MediaController mediaController = new MediaController(mActivity);
mediaController.setAnchorView(VideoViewplayer);
VideoViewplayer.setMediaController(mediaController);
VideoViewplayer.setVideoURI(Uri.parse("a URL" + ".mp4"));
VideoViewplayer.start();
答案 0 :(得分:0)
试试这个:
Uri video = Uri.parse(url);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(VideoViewplayer);
VideoViewplayer.requestFocus();
VideoViewplayer.setMediaController(mediaController);
VideoViewplayer.setVideoURI(video);
VideoViewplayer.setOnPreparedListener(new OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer arg0)
{
VideoViewplayer.start();
}
});