Oren Kochansky Oren Kochansky - 5 months ago 11
Android Question

Use intent to play several video files in Android

I am trying to play videos in the user's default video player. I want them to play one after another (like a playlist). Currently I know how to play only one (see the code below). Can I open a folder or list of files ?

Here's my code:

final Intent playIntent = new Intent(android.content.Intent.ACTION_SEND);
playIntent.setType("video/*");
playIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://" + filePath));
mContext.startActivity(Intent.createChooser(playIntent, "Play videos list"));

Answer

Currently I know how to play only one (see the code below)

That will not necessarily play a video. That is ACTION_SEND, and many, if not most, video player apps will not be expecting that Intent structure. VLC, for example, does not support this. ACTION_VIEW is far more common here.

Can I open a folder or list of files ?

Not really. A small percentage of video player apps support ACTION_SEND. An even smaller percentage of video player apps support ACTION_SEND_MULTIPLE. There is no equivalent for ACTION_VIEW to view a collection of items.

Comments