Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Help: How do open a remote Video file URL to play in MediaPlayer without having to open a browser window?

How do open a remote Video file URL from a button click to play in the internal MediaPlayer without having to open a browser window?

The video plays fine, but it always opens a browser window 1st which is annoying.

This is what i am using already, but is it possible to launch the mediaplayer without the app opening a browser window first.

Hope someone can help

Thanks Lucy

final Button button = (Button) findViewById(R.id.play);  
     button.setOnClickListener(new Button.OnClickListener() {  
         public void onClick(View v) {  
             // Perform action on click 
             Uri uri = Uri.parse("http://domain.com/videofile.mp4");
             Intent intent = new Intent(Intent.ACTION_VIEW, uri);

             startActivity(intent);

            }

     });  
 }  
like image 957
lucy Avatar asked Jan 06 '11 20:01

lucy


1 Answers

Try this:

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.parse(videoPath), "video/mp4");
startActivity(intent);
like image 108
dinesh sharma Avatar answered Sep 27 '22 19:09

dinesh sharma