如何显示同时表面观两段视频 [英] How to display two videos simultaneously with surface view

查看:134
本文介绍了如何显示同时表面观两段视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于如何显示同时表面观两段视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆