android: using default video player

Farhan  picture Farhan · Oct 27, 2011 · Viewed 8.9k times · Source

I have an application that plays video files.

I have been using code for using Videoview and starting the Videoview manually to play video files. However, I just wanted to know if I can use the default media player or video player of android rather than creating or using the VideoView to play the file..

Please make comments if the question is not clear.

Thanks alot

Answer

Michell Bak picture Michell Bak · Oct 27, 2011

Sure - just use an Intent with the file Uri.

File file = new File("fileUri");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);