侦听器(或者处理程序)的视频结束 [英] Listener (or handler) for video finish

查看:117
本文介绍了侦听器(或者处理程序)的视频结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有实现以下code,以测试通过it's网址正在从远程Web服务器的视频。

I have implement the following code in order to test playing a video from a remote web server through it´s URL.

videoView = (VideoView)this.findViewById(R.id.videoView);
        MediaController mc = new MediaController(this);
        videoView.setMediaController(mc);
        videoView.setVideoURI(Uri.parse("http://sayedhashimi.com/downloads/android/movie.mp4"));
        videoView.requestFocus();

在code为工作得很好,即使是在Android模拟器。我只是想知道是否有任何监听器(或者处理程序)来检测被再现的视频的完成?

The code is working just fine, even in the Android emulator. I just would like to know if there's any listener (or handler) to detect the finish of the video that is being reproduced?

我有以下的code现在:

I have the following code now:

   @Override
        protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.player);

        videoView = (VideoView)this.findViewById(R.id.videoView);
        playVideo();

        // video finish listener
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
                // not playVideo
                            // playVideo();

                            mp.start();
            }
        });
    }

    public void playVideo() {
            MediaController mc = new MediaController(this);
            videoView.setMediaController(mc);
            videoView.setVideoURI(Uri.parse("http://sayedhashimi.com/downloads/android/movie.mp4"));
            videoView.requestFocus(); 
        }

在活动刚打电话,视频工作正常,但是当视频结束后,我想,这再次播放,它不是发生。

When the activity is just called, the video works fine but when the video finishes, I would like that it played again, which it's not occurring.

推荐答案

好像你正在寻找

setOnCompletionListener(MediaPlayer.OnCompletionListener l)

更多深入的解释可以发现这里

More in depth explanation can be found here

<一个href="http://groups.google.com/group/android-beginners/browse%5Fthread/thread/82bae0bbcee85fb4">This显示了在那里播放结束后,用所谓的解决方案 VideoView 的MediaController setOnCompletionListener()

This shows a solution where playback is called after completion using VideoView, MediaController and setOnCompletionListener().

这篇关于侦听器(或者处理程序)的视频结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆