播放视频时出错
当我想在我的应用程序上播放视频时,出现奇怪的错误。到目前为止,视频播放正常,但现在我在 Samsung Android 手机上收到此错误:
02-13 09:35:58.132: I/System.out(4189): Add Video to RelativeLayout
02-13 09:35:58.242: W/MediaPlayer(4189): info/warning (1, 26)
02-13 09:35:58.247: E/MediaPlayer(4189): SISO TEST MEDIA_ERROR
02-13 09:35:58.247: E/MediaPlayer(4189): error (-4, -4)
02-13 09:35:58.287: I/MediaPlayer(4189): Info (1,26)
02-13 09:35:58.287: E/MediaPlayer(4189): Error (-4,-4)
02-13 09:35:58.287: D/VideoView(4189): Error: -4,-4
02-13 09:35:58.287: I/System.out(4189): onError-error play video
在 Xperia 上收到此错误:
02-13 09:39:26.331: I/System.out(10864): Add Video to RelativeLayout
02-13 09:39:26.381: E/MediaPlayer(10864): error (1, -2147483648)
02-13 09:39:26.401: E/MediaPlayer(10864): Error (1,-2147483648)
02-13 09:39:26.401: D/VideoView(10864): Error: 1,-2147483648
02-13 09:39:26.401: I/System.out(10864): onError-error play video
其中 "onError-error play video"
是来自 onErrorListener 的消息。我从 SD 卡中删除了视频并重新放入,但遇到了同样的问题。怎么了?
这是我的代码,我将 VideoView 添加到relativelayout:
public void onAnimationStart(Animation animation) {
myVideoView = new VideoView(getApplicationContext());
myVideoView.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
myVideoView.setVideoURI(Uri.parse(Environment .getExternalStorageDirectory()+ "/BouyguesSlideShow"+ "idPlaylist"+ "/" +vf.getCurrentView().getTag().toString()));
myVideoView.requestFocus();
myVideoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError( MediaPlayer mp, int what,int extra) {
System.out.println("onError-error play video");
return true;
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
System.out.println("Anim end "
+ vf.getDisplayedChild());
if ((vf.getCurrentView().getTag().toString()
.endsWith("Video"))
|| (vf.getCurrentView().getTag().toString()
.endsWith("Video.mp4"))) {
System.out
.println("Add Video to RelativeLayout");
((ViewGroup) vf.getCurrentView())
.addView(myVideoView);
myVideoView.bringToFront();
myVideoView.start();
vf.stopFlipping();
}
}
I get strange errors when I want to play videos on my app. Until now videos played ok, but now I get this error on Samsung Android Phone:
02-13 09:35:58.132: I/System.out(4189): Add Video to RelativeLayout
02-13 09:35:58.242: W/MediaPlayer(4189): info/warning (1, 26)
02-13 09:35:58.247: E/MediaPlayer(4189): SISO TEST MEDIA_ERROR
02-13 09:35:58.247: E/MediaPlayer(4189): error (-4, -4)
02-13 09:35:58.287: I/MediaPlayer(4189): Info (1,26)
02-13 09:35:58.287: E/MediaPlayer(4189): Error (-4,-4)
02-13 09:35:58.287: D/VideoView(4189): Error: -4,-4
02-13 09:35:58.287: I/System.out(4189): onError-error play video
and this error on Xperia :
02-13 09:39:26.331: I/System.out(10864): Add Video to RelativeLayout
02-13 09:39:26.381: E/MediaPlayer(10864): error (1, -2147483648)
02-13 09:39:26.401: E/MediaPlayer(10864): Error (1,-2147483648)
02-13 09:39:26.401: D/VideoView(10864): Error: 1,-2147483648
02-13 09:39:26.401: I/System.out(10864): onError-error play video
where "onError-error play video"
is the message from onErrorListener. I deleted the videos from SD card and put them again but I get the same problem. What's wrong?
Here is my code where I add the VideoView to RelativeLAyout:
public void onAnimationStart(Animation animation) {
myVideoView = new VideoView(getApplicationContext());
myVideoView.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
myVideoView.setVideoURI(Uri.parse(Environment .getExternalStorageDirectory()+ "/BouyguesSlideShow"+ "idPlaylist"+ "/" +vf.getCurrentView().getTag().toString()));
myVideoView.requestFocus();
myVideoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError( MediaPlayer mp, int what,int extra) {
System.out.println("onError-error play video");
return true;
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
System.out.println("Anim end "
+ vf.getDisplayedChild());
if ((vf.getCurrentView().getTag().toString()
.endsWith("Video"))
|| (vf.getCurrentView().getTag().toString()
.endsWith("Video.mp4"))) {
System.out
.println("Add Video to RelativeLayout");
((ViewGroup) vf.getCurrentView())
.addView(myVideoView);
myVideoView.bringToFront();
myVideoView.start();
vf.stopFlipping();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论