Thursday 27 December 2012

VideoPlayerDemo

Demo:



1) Activity:
 
package com.venky.videoplayerdemo;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class MainActivity extends Activity {

      VideoView vv;

      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            vv = (VideoView) findViewById(R.id.videoView1);

            vv.setMediaController(new MediaController(MainActivity.this));

            vv.setVideoURI(Uri.parse("sdcard/dts.3gp"));

            vv.start();

      }

}


2)main.xml:
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:gravity="center"
        android:text="Video Player Demo"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <VideoView
        android:id="@+id/videoView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>


3)Download this Project Click Here
 

No comments:

Post a Comment