如何显示同时表面观两段视频

如何显示同时表面观两段视频

问题描述:

我在Android开发初学者。
我试图显示与利用媒体codeC对此我成功的面查看视频。
现在,我想在此必须要显示或隐藏按照用户的意愿,或在两者之间切换运行时间增加一个视频。
我可以有一些建议,一样的...

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...

谢谢......

试试这个

    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();
    }
}

您XML code应该是这样的:

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.