Reputation: 844
i know there is VideoView can play given stream URL. but is that possible to play video that is from download URL?
Upvotes: 0
Views: 1163
Reputation: 292
public class HomeActivity extends Activity {
String url = "Type your url here ";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
myVideoView.setVideoURI(Uri.parse(url));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}
}
Upvotes: 0
Reputation: 844
it can be other option , playing video in Default Player
String extension = MimeTypeMap.getFileExtensionFromUrl("video url");
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
Intent mediaIntent = new Intent(Intent.ACTION_VIEW);
mediaIntent.setDataAndType(Uri.parse("video url"), mimeType);
startActivity(mediaIntent);
Upvotes: 1