0

I am a beginner in android development. I was trying to display a video with surface view using media codec for which i am successful. Now I want to add one more video at run time which has to be displayed or hidden as per the wish of the user or to switch between the two. Can I have some suggestions for the same...

Thanks......

Kevin K
  • 589
  • 2
  • 7
  • 28

1 Answers1

0

Try this

    public class CustomPictureActivity extends Activity {
    /** Called when the activity is first created. */
    VideoView vd1,vd2;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        vd1=(VideoView) findViewById(R.id.v1);
        vd2=(VideoView) findViewById(R.id.v2);
        vd1.setVideoURI(Uri.parse("/mnt/sdcard/file.mp4"));
        vd1.setMediaController(new MediaController(this));
        vd1.requestFocus();
        vd1.start();

        vd2.setVideoURI(Uri.parse("/mnt/sdcard/android.mp4"));
        vd2.setMediaController(new MediaController(this));
        vd2.requestFocus();
        vd2.start();
    }
}

Your xml code should be like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >

<VideoView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.5" 
    android:id="@+id/v1"/>

<VideoView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.5" 
    android:id="@+id/v2"/>

</LinearLayout>

May this will help you.

Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138