视频结束后结束活动

发布于 2024-11-25 01:01:02 字数 198 浏览 0 评论 0原文

您好,我是 Android 开发新手,正在开发一款游戏。现在我有一个过场动画,这是按下游戏开始按钮后调用的视频视图。我希望能够在视频结束后立即结束过场动画活动,但我不知道该怎么做。起初我尝试在 onCreate 中设置一个 25 秒的计时器,但失败了,因为 onCreate 只发生一次。现在我有一个结束过场动画的按钮,但我的问题是如何让过场动画结束并在视频直接结束后调用游戏活动?

Hi I am new to android development and I'm working on a game. Right now I have a cutsceen right now which is a videoview that is called after hitting the start button of the game. I want to be able to be able to end the cutsceen activity immediately after the video ends, but I'm not sure how to do that. At first I tried putting a timer for 25 seconds in onCreate, but that failed since onCreate only happens once. As it is now I have a button to end to the cutsceen, but my question is how do I get the cutsceen activity to end and call the game activity after the video directly ends?

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

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

发布评论

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

评论(2

淡墨 2024-12-02 01:01:02

首先,我不太熟悉游戏开发,但我想它也会以同样的方式工作。不管怎样,视频是在 VideoView 中吗?如果是这样,您可以调用 setOnCompletionListener ,这样您就会收到视频播放完毕的通知。

然后,您可以在回调方法中的活动。

public void onCompletion(MediaPlayer mp) {
    finish(); //This will end the current activity
}

First off, I'm not really familiar with game development, but I guess it would work the same way. Anyway, is the video in a VideoView? If so, you can call setOnCompletionListener to it so you will be notified that the video is done playing.

You can then call finish() on the activity in the callback method.

public void onCompletion(MediaPlayer mp) {
    finish(); //This will end the current activity
}
素食主义者 2024-12-02 01:01:02
myVideoView.setOnCompletionListener(new OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            // TODO Auto-generated method stub

           //write your code after complete video play  
        }
    });
myVideoView.setOnCompletionListener(new OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            // TODO Auto-generated method stub

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