2

I have video player, video is from url. It works- I can start and stop playing video. I would like to have a possibility to move progres in MediaController. I have set the MediaController, but it doesn't work. When I use a video from file i can seek/move the video progress, but with the video from url it doesn't work. There is my code:

videoFrame = (FrameLayout) findViewById(R.id.videoField);
mediaController = new MediaController(VideoPage.this);
videoPlayer = new VideoView(context);
videoFrame.addView(videoPlayer);
videoPlayer.setVideoURI(Uri.parse(url));
mediaController.setMediaPlayer(videoPlayer);
videoPlayer.setMediaController(mediaController);
videoPlayer.requestFocus();
videoPlayer.start();
Cœur
  • 37,241
  • 25
  • 195
  • 267
Piotr Kuk
  • 21
  • 1
  • 3

1 Answers1

2

You have to check if you can seek forward:

if(videoPlayer.canSeekForward()){
   ...
}

and this is just possible, when you get a duration for the videostream, but some streams don't have a duration, for example if you stream tv content or a live stream.

int duration = videoPlayer.getDuration()
Duglah
  • 41
  • 4