Video playback in VideoView may stop after 15 seconds.

Asked 2 years ago, Updated 2 years ago, 30 views

I play videos using VideoView on Android 4.4.2.
Videos are distributed from the network in http live streaming format.

Pressing the button

VideoView videoView= (VideoView) findViewById (R.id.videoview);
videoView.seekTo(videoView.getCurrentPosition()+15000);
videoView.start();

is called, and it goes 15 seconds further, but sometimes it works and sometimes it doesn't. When it doesn't work, the video screen stays still and when you press the button again, it doesn't work.
Why does this happen?Also, if there is a solution, please let me know.

android

2022-09-30 14:36

1 Answers

I tried as follows, but the symptom was not reproduced.
Play without stopping

The desired behavior is
·When the video is ready, the video starts with a pre-specified number of seconds
·After that, it will be played without any problems
Would that be all right?

String VideoURL="http://www.androidbegin.com/tutorial/AndroidCommercial.3gp";
    // String VideoURL="http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8";


    VideoView videoView= (VideoView) rootView.findViewById (R.id.VideoView);

    try{

        mediacontroller = new MediaController(
                This.getActivity());
        mediacontroller.setAnchorView (videoview);

        Uri video=Uri.parse (VideoURL);
        videoview.setMediaController(mediacontroller);
        videoview.setVideoURI(video);

    } catch(Exceptione){
        Log.e("Error", e.getMessage());
        e.printStackTrace();
    }

    videoview.requestFocus();
    videoview.setOnPreparedListener(newMediaPlayer.OnPreparedListener(){

        public void onPrepared (MediaPlayermp) {
            videoview.seekTo(videoview.getCurrentPosition()+15000);
            videoview.start();

            handler.post(new Runnable(){

                @ Override
                public void run() {
                    mediacontroller.setEnabled(true);
                    mediacontroller.show(0);

                }
            });
        }
    });


2022-09-30 14:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.