视频播放器不能播放视频每次 [英] Video Player Does not Play the Video Every time
问题描述
我的工作中,我要使用Android视频播放器的应用程序。我给这个球员是一个URI,有时运行并有一段时间没有。 URI被根据所定义的程序在运行时产生的。
I am working on an application in which I have to use Android Video Player. I am giving this Player a URI, that sometime runs and some time does not. URI is generated at run time according to a defined procedure.
我得到的logcat以下错误,当视频不会播放。
I get the following error in logcat when video does not get played.
03-30 12:58:42.918: D/MediaPlayer(4948): Couldn't open file on client side, trying server side
03-30 12:58:43.516: E/MediaPlayer(4948): error (1, -1004)
03-30 12:58:43.516: E/MediaPlayer(4948): Error (1,-1004)
03-30 12:58:43.520: D/VideoView(4948): Error: 1,-1004
我无法理解这个错误。如有任何人都可以给我讲解一下。它是在我(的VideoPlayer的)末端或服务器端的问题.. ???
I am unable to understand this error. Please if anyone can explain this to me. Is it an issue at my (VideoPlayer's) end or Server end..???
使用视频播放器code上午如下:
The Code am using for Video Player is as follows:
String url = getIntent().getExtras().getString("videourl");
VideoView videoView = (VideoView) findViewById(R.id.videoview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
还有一件事是,在不播放的视频,我得到一个错误对话框,其中显示:
One thing more that, when video is not played, I get an Error dialog which shows:
对不起!该视频无法播放与确定按钮。当我preSS按钮,视图不弹出回我的应用程序的previous窗口,而是保持的VideoPlayer屏幕上,我不得不preSS后退按钮两次以返回到previous视图。为什么会这样?..任何有助于有关问题的解释是很多很多AP preciated。
"Sorry! This video cannot be played."with an "ok" button. When I press the button, the view does not pops back to my app's previous window, rather it remain on VideoPlayer screen and I have to press back button twice to get back to the previous view. Why is it so..??? Any helps about the explained issues is much much appreciated.
推荐答案
形式记录-1004意味着:
公共静态最终诠释MEDIA_ERROR_IO
form log -1004 means: public static final int MEDIA_ERROR_IO
对于我来说,这个工程总:
for me, this works always:
Uri video = Uri.parse(url);
mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.requestFocus();
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer arg0)
{
videoView.start();
}
});
这篇关于视频播放器不能播放视频每次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!