如何使用libvlc在surfaceView上显示流式视频的进度条?

时间:2017-08-01 10:43:39

标签: android libvlc

我使用libvlc(de.mrmaffen:vlc-android-sdk:1.0.6)库来进行http视频流传输。一切都很好,只有一个问题。

我在playmovie()函数调用之前使用了progress-bar,并使用libvlc.isPlaying()布尔函数停止进度条,所以此时我的猜测是视频已加载,我们将停止进度条。

如何获得缓冲视频和流媒体开始停止进度条的确切时间?

1 个答案:

答案 0 :(得分:1)

你需要以这种方式实现EventListener.Like

LibVLC vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
org.videolan.libvlc.MediaPlayer player = new org.videolan.libvlc.MediaPlayer(vlcInstance);
        player.setEventListener(new org.videolan.libvlc.MediaPlayer.EventListener() {
            @Override
            public void onEvent(org.videolan.libvlc.MediaPlayer.Event event) {
                switch (event.type) {
                    case org.videolan.libvlc.MediaPlayer.Event.Opening:
                        //Video Opening
                        break;
                    case org.videolan.libvlc.MediaPlayer.Event.Playing:
                        //Video Playing
                        break;
                    case org.videolan.libvlc.MediaPlayer.Event.Buffering:
                        //Video Buffering
                        break;
                    case org.videolan.libvlc.MediaPlayer.Event.Stopped:
                        //Video Stopped
                        break;
                    case org.videolan.libvlc.MediaPlayer.Event.EndReached:
                        //Video EndReached/Completed
                        break;
                    case org.videolan.libvlc.MediaPlayer.Event.EncounteredError:
                        //Video EncounteredError/Failed
                        break;
                    default:
                        break;
                }
            }
        });

 Media media = new Media(vlcInstance, videoUri);
            media.addOption(":fullscreen");
            media.setHWDecoderEnabled(true, false);
            player.setMedia(media);
            IVLCVout vlcOut = player.getVLCVout();