How to solve the problem that the video cannot be played from scratch?

  android, question

请输入图片描述

At present. I can use Intent Chooser to open different video files. Therefore, it is not difficult to imagine that when clicking this item, there will always be a large number of video file lists.
The code I use is:

Intent intent = new Intent(Intent.ACTION_VIEW);
 intent.setDataAndType(uriPath, "video/mp4");
 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

However, when the user clicks the same item again, the image selector will pop up: please select the correct video player to resume the video in the device.

So, my question is, is there any flag or other method to let the video play directly from the beginning?

This situation exists not only in video files, but also in pdf files. If a pdf file runs and has been scrolled to end page, if the file is opened again, it will still be parked in end page.


Original text:Video automatically resumed when using Intent Chooser?

A: amIT
I have encountered similar problems. My method is to test the application first, and then see if the video of the application will restore the previous image after starting it again. My video has always been played from scratch, using the following code:

Intent in = new Intent(Intent.ACTION_VIEW);
 in.setDataAndType(uripath, "video/*");
 startActivity(in);

A: Priyanka Minhas
VideoView can be used to solve your problem:

privateVideoViewmyVideoView;

There is a built-in method in VideoView-Start (), which will let your video play from scratch. The implementation method is as follows:

@Override
 public void onStart(){
 super.onStart();
 myVideoView.start();
 bracket

Of course, you can also use myVideoView.start () in onResume to solve your problem.