I’ve tried to find a simple tutorial which explains how to load a video from a URL into the android media player but unfortunately I couldn’t find any!
I have tried several things to try get it working but still no luck.
What is the best way to have a MediaPlayerActivity just load a video from a URL?
Thanks
EDIT:
I have tried the following code as suggested:
VideoView videoView = (VideoView) findViewById(R.id.your_video_view);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI(Uri.parse("url-here"));
videoView.start();
It just crashes when I go to this activity.
You can use a VideoView. Here is an example:
EDIT
You should provide the URI (having a
String urlvariable, where it has the url of the video) with this codeUri.parse(url). And also be sure if the url is appropriate. Also, have you provided the appropriate permissions to your app, as AkashG suggested, (since it uses the internet you will need to add<uses-permission android:name="android.permission.INTERNET" >in your app’sManifest.xml)? Finally you should define your activityMediaPlayerActivityin in your app’sManifest.xmlEnd of EDIT
You can also use MediaPlayer. The Android developers site has a good tutorial here.