0

In my project i was implemented the videoview for streaming videos. It is taking lot of time for loading and buffering the videos where as other players or browser taking far lesser time then videoview.. I was searching in internet from a couple of days couldn't able to find the proper solution for my case. I am loading the videos from Amazon S3 bucket i don't think it is because of server

    private void playVideo() {

    vidUri = Uri.parse(movieUrl);

    vidControl = new CustomMediaControl(this, new CustomMediaControl.MediaFullScreen() {
        @Override
        public void fullScreenButtonClicked() {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }

        @Override
        public void fullScreenButtonExited() {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    });

    videoPlayer.setMediaController(vidControl);

    videoPlayer.setVideoURI(vidUri);

    videoPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            // TODO Auto-generated method stub
            mp.start();
            mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                @Override
                public boolean onInfo(MediaPlayer mp, int what, int extra) {
                    switch (what) {
                        case MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START: {
                            progressBar.setVisibility(View.GONE);
                            return true;
                        }
                        case MediaPlayer.MEDIA_INFO_BUFFERING_START: {
                            progressBar.setVisibility(View.VISIBLE);
                            return true;
                        }
                        case MediaPlayer.MEDIA_INFO_BUFFERING_END: {
                            progressBar.setVisibility(View.GONE);
                            return true;
                        }
                    }
                    return false;
                }
            });
        }
    });
    videoPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        @Override
        public boolean onError(MediaPlayer mp, int what, int extra) {
            Log.e("Media Details", "hello");
            return true;
        }
    });

    videoPlayer.start();
    videoPlayer.seekTo(stopPosition);

}

I was also looked into the below links Link1 and Link2. Let me know if you need more clarity

Bala Saikrupa Puram
  • 721
  • 1
  • 7
  • 28
  • you are creating CustomMediaControl everytime when you are going to play the video ,create only when it vidControl is null – Ajay Chauhan Oct 23 '18 at 11:02
  • okay but i am calling this method only in onCreate so how does it matters with loading time – Bala Saikrupa Puram Oct 23 '18 at 12:03
  • @saikrupa How much time it is taking for loading? What is the protocol is it RTSP? – kiran Biradar Oct 24 '18 at 06:23
  • Open your video file in a hex editor (to see bytes), now tell me can you see **mdat** or **moov** written on first page and without any scrolling down?. If **mdat** atom is first, then you need to use a tool to move that **moov** atom to be in front. Moov tells player how to display and must be seen first, mdat is just media data. – VC.One Oct 26 '18 at 02:07

0 Answers0