1

I'm trying to play the following video on all devices. The problem is that with Android 4.1.2 the getDuration is 1476000 AKA 24:36 minutes. With Android 5.0.2 the getDuration returns 1546347 AKA 25:46 minutes.

So on Android 4.1.2 the real problem is that the video continues to play after "being finished". But the reality is that the video should have a getDuration like on Android 5.0.2. Does anyone here have any clue?

To see the UI problem: https://i.stack.imgur.com/tRAg5.jpg

Code below:

private void crearVideoPlayer(String videoURL) {
    // Find your VideoView in your video_main.xml layout
    videoview = (VideoView) findViewById(R.id.VideoView);

    videoControls = new MediaController(this);
    videoview.setMediaController(videoControls);
    // Start the MediaController
    videoControls.setAnchorView(videoview);

    // Get the URL from String VideoURL
    Uri video = Uri.parse(videoURL);

    videoview.setOnCompletionListener(this);
    videoview.setOnTouchListener(this);

    videoview.setVideoURI(video);

    videoview.requestFocus();
    videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        // Close the progress bar and play the video
        public void onPrepared(MediaPlayer mp) {
            pDialog.dismiss();
            videoview.start();
        }
    });

}
Tef
  • 23
  • 7

0 Answers0