播放视频时出错

发布于 2025-01-04 14:56:49 字数 2835 浏览 1 评论 0原文

当我想在我的应用程序上播放视频时,出现奇怪的错误。到目前为止,视频播放正常,但现在我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文