1

i have an mp4 i am trying to view on my android in a video view but for some reason when i use seekto i can only seek to every 10 seconds. if i seek to 34 seconds it seeks to 30 and if i seek to 36 it seeks to 40. and so on for every thing i try to seek to. i have heard something about seek points in an mp4 file. is this whats causing my seek to fail?

    videoView = (VideoView)findViewById(R.id.watchMp4View);
            videoView.setVideoURI(Uri.parse(uri));
            videoView.requestFocus();
            videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mediaPlayer) {




                        videoView.seekTo(timeToSkip); //
                        mediaPlayer.seekTo(timeToSkip);
                        mediaPlayer.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() {
                            @Override
                            public void onSeekComplete(MediaPlayer mediaPlayer) {
                                videoView.start();

 }
                        });
Tomer Shemesh
  • 10,278
  • 4
  • 21
  • 44

1 Answers1

1

this issue is related to the creation of the .mp4 file, your file need to be prepared to allow seeking, in the encoding process check the Keyframe property, try with a shorter keyframe.

Jorgesys
  • 124,308
  • 23
  • 334
  • 268