sagar potdar
sagar potdar

Reputation: 608

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

I used libvlc (de.mrmaffen:vlc-android-sdk:1.0.6) library for http video streaming. Everything works fine just one issue.

I used progress-bar before my playmovie() function call,and stop the progress-bar with using libvlc.isPlaying() boolean function so at this time my guess is video is loaded and we will stop the progressbar.

How to get exact time for buffering the video and streaming start to stop the progressbar?

Upvotes: 4

Views: 1430

Answers (1)

Bhavya Gandhi
Bhavya Gandhi

Reputation: 507

You need to implement EventListener.Like this 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();

Upvotes: 2

Related Questions