Last Updated: February 25, 2016
·
691
· danielerigo

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