How to show progressbar for streaming video on surfaceView with libvlc?

I have used libvlc library (de.mrmaffen: vlc-android-sdk: 1.0.6) to stream HTTP video. Everything works fine only one problem.

I used a progress bar before calling playmovie () and stopped the progress bar with the boolean libvlc.isPlaying () function, so at this time my guess is loading and we will stop the progress bar.

How do I get the exact time for video buffering and streaming start to stop the progress bar?

+3


source to share


1 answer


You need to implement EventListener. In a similar way



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();

      

0


source







All Articles