play video on center


VideoView’s onMeasure to scale up the video to fit inside a fullscreen view.

  setContentView(R.layout.wellcome);
        VideoView videoView = (VideoView) this.findViewById(R.id.videoView1);
        uri = "android.resource://" + getPackageName() + "/" + R.raw.tour;
        videoView.setVideoURI(Uri.parse(uri));
        videoView.requestFocus();
        videoView.setOnPreparedListener(new OnPreparedListener(){
        	public void onPrepared(MediaPlayer mp){
        		mp.setLooping(true);
        	}
        });
        videoView.start();
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg">
<!-- Video player -->
<VideoView android:id="@+id/surface_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center">
</VideoView>
</FrameLayout>

Screen Shot 2015-02-27 at 8.46.15 AM


Leave a Reply