Video streaming on Android
In your xml layout add a VideoView:
<VideoView android:id="@+id/videoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
In the class add the following code:
VideoView videoView;
videoView = (VideoView)this.findViewById(R.id.videoView);
videoView.setVideoURI(Uri.parse("http://www.pocketjourney.com/downloads/pj/video/famous.3gp"));
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
videoView.setMediaController(mc);
videoView.requestFocus();
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
videoView.start();
}
});
This are the supported Media Formats:
https://developer.android.com/guide/appendix/media-formats.html
Written by Daniele Rigo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#