Video automatically resumes when using Intent Chooser

I have an application that opens different videos using the Intent selection. Thus, you can imagine that the user clicks on a list item that contains many items with the name of the video.

Now everything works fine with this,

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

but when the user clicks on the same item again, a choice of intent is displayed. Selecting a video player on the device resumes the video.

So the question is, is there any flag or some way in which the video can be started from the very beginning?

This thing happens not only with video, but also with pdf. If the PDF was opened and scrolls to the last page, then again opening the PDF from my application opens it with the last page.

+3
source share
5 answers
 hi hardikI had a similar application to be developed where  different 

Videos should play when you select different items from the list.

I tried to test my application for behavior that resumes video from the last frame being played if it starts again from the application.

For me, it always starts from the very beginning. I tested it on 4.2.2 and only version 4.4

The code to run the video was something like this:

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

This question has already been asked the intention of Android to start the game with an initial position , especially in this comment CommonsWare

Even if there were, they would be on a per-app basis.
If you need this level of control over the video playback,
handle the video playback yourself within your own app 
(e.g., VideoView), rather than pass control to third party apps

See http://developer.android.com/reference/android/widget/VideoView.html#seekTo(int) and Play video in VideoView in Android

, , . , , , PDF. - http://code.google.com/p/apv/.

+1

, , . ( , ), , .

.

0

VideoView .

private VideoView myVideoView;

VideoView has a built-in start () method that will start your video from the very beginning as follows:

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

You can also use myVideoView.start () for the onResume method.

Hope this helps. :)

-1
source

I am completely unsure of this. I also agree with other opinions that the responsibility for this intention lies with the named Application.

However, a wild guess would be to change the uri:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(
    uriPath.buildUpon()
        .appendQueryParameter("t", String.valueOf(System.currentTimeMillis()))
        .build(), 
    "video/mp4"
);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Note. I did not have the problem you mention. The video always reloads.

-1
source

All Articles