4

I need to user choice their own player to play video and I try

public class VideoViewActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String videoUrl = "http://someurl/video.mp4";
        Intent i = new Intent(Intent.ACTION_VIEW);  
        i.setData(Uri.parse(videoUrl));  
        startActivity(i); 
}

But in my example activity open browser not a list of current installed player. Which option of Intent I should use? Is it possible?

2 Answers2

7

Please try below code.

String videoUrl = "http://someurl/video.mp4";
Intent i = new Intent(Intent.ACTION_VIEW);  
i.setDataAndType(Uri.parse(videoUrl),"video/mp4");  
startActivity(i); 
Nikhil
  • 16,194
  • 20
  • 64
  • 81
1

The schema is "http", so the webview will be open.

this is a stream video, try to download it firstly. and then open it.

Changwei Yao
  • 13,051
  • 3
  • 25
  • 22
  • 1
    Thank you ! You are right, but if I use "Nik...." example I can select browser or player. But in my example url directly opens in default browser. –  May 03 '12 at 11:29