视频视图不可见

发布于 2024-12-20 06:18:28 字数 1142 浏览 2 评论 0原文

我需要将 VideoView 添加到 LinearLayout,然后将 LinearLayout 添加到 ViewFlipper。这是我的代码:

            LinearLayout l = new LinearLayout(this);
            l.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT));

            l.setOrientation(LinearLayout.VERTICAL);

                myVideoView = new VideoView(this);
                myVideoView.setVideoPath(files[i].getPath());
                myVideoView.requestFocus();

                myVideoView.setLayoutParams(new LayoutParams(
                        l.getWidth(), l.getHeight()));
                myVideoView.setKeepScreenOn(true)

                myVideoView.start();
                myVideoView.setId(i);
                l.addView(myVideoView);
                vf.addView(l);

问题是我看到所有屏幕都是白色的并听到视频的声音,因为视频正在播放但我看不到它。为什么?问题出在哪里?

编辑:

如果我让它

myVideoView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT));

工作,但视频速度并不慢,当图像出现时,它会突然出现。我希望那个视频像这样慢慢出现然后消失。

I need to add a VideoView to a LinearLayout, and then to add LinearLayout to ViewFlipper. Here is my code :

            LinearLayout l = new LinearLayout(this);
            l.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT));

            l.setOrientation(LinearLayout.VERTICAL);

                myVideoView = new VideoView(this);
                myVideoView.setVideoPath(files[i].getPath());
                myVideoView.requestFocus();

                myVideoView.setLayoutParams(new LayoutParams(
                        l.getWidth(), l.getHeight()));
                myVideoView.setKeepScreenOn(true)

                myVideoView.start();
                myVideoView.setId(i);
                l.addView(myVideoView);
                vf.addView(l);

The problem is that I see all screen white and hear the video's sound, because video is playing but I don't see it. Why? Where is the problem?

EDIT :

if I put

myVideoView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT));

it works but the video is not coming slow, as image appear, it appears suddenly. I want that video to appear slowly and to dissapear like this to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云淡月浅 2024-12-27 06:18:28

试试这个:

LayoutParams layout = new LayoutParams(l.getWidth(), l.getHeight()));

...

l.addView(myVideoView, layout);

Try this:

LayoutParams layout = new LayoutParams(l.getWidth(), l.getHeight()));

...

l.addView(myVideoView, layout);
2024-12-27 06:18:28

注释 myVideoView.setKeepScreenOn(true) 行并检查一次。

comment the line myVideoView.setKeepScreenOn(true) and check once.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文