7

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

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
Farhan
  • 3,206
  • 14
  • 49
  • 62

1 Answers1

11

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);
Michell Bak
  • 13,182
  • 11
  • 64
  • 121
  • Sir, is it possible to provide a path rather than uri in a string? Moreover Sir, do you have any ideas about what other parameters can be passed like seekto etc? Your help will be appreciated.. Thanks – Farhan Oct 26 '11 at 23:14
  • 1
    You need to pass the path of the file. You can do it like this: Uri.parse("filepath"). I don't believe it's possible to pass other parameters, sadly. – Michell Bak Oct 26 '11 at 23:17
  • Sir, is there any other method because for some reason, the default video is unable to play the file.. I am not sure why.. Can you explain any other method.. Thanks – Farhan Oct 31 '11 at 08:41
  • 1
    You can find all supported media formats in Android here: http://developer.android.com/guide/appendix/media-formats.html – Michell Bak Oct 31 '11 at 09:47
  • Is it possible to start the video at a desired time? Can't find anywhere in the docs about this – Paulo Cesar Aug 15 '12 at 20:43
  • There's no standard API for that. Some video players do support it with intent extras, though. – Michell Bak Aug 15 '12 at 21:04