Issue
I am using the following intent to play a video with the android default Video Player.
File file = new File(galleryList.get(getAbsoluteAdapterPosition()).getPath());
Intent i = new Intent(Intent.ACTION_VIEW);
if (GalleryMediaHelper.isVideoFile(galleryList.get(getAbsoluteAdapterPosition()).getPath())) {
i.setDataAndType(FileProvider.getUriForFile(context, AUTHORITY, file), "video/*");
}
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION);
if (i.resolveActivity(context.getPackageManager()) != null)
context.startActivity(i);
So far so good. The video player starts playing the video. The problem is that, when the video is played the video player is closed and the user returns to the my app. -> NOK
How can I force video player to not close and either play on repeat the video or just wait for user to press back to exit video player?
Solution
The problem is that, when the video is played the video player is closed and the user returns to the my app
That behavior will depend on the video player app. There are hundreds, if not thousands, of possible video player apps that might handle your Intent
, based on pre-installed and user-installed video player apps.
How can I force video player to not close and either play on repeat the video or just wait for user to press back so that he can do whatever he/she wants with the video player (pause, stop, replay etc)?
That is not possible. The behavior of a video player app is up to the developers of that app.
If you need that level of control over the user experience, implement your own video player, such as by integrating ExoPlayer.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.