如何在Wikitutde Android Native APi中识别目标上的CustomeSurfaceview上播放视频?

时间:2015-11-20 04:23:16

标签: android sdk surfaceview augmented-reality wikitude

我想在服装表面视图上播放视频,但是已完成,但视频未在服装表面视图上显示。我正在使用Wikitude SDK。 这是我的代码........

我在这里设置我的用户界面......

@Override
    public void onRenderExtensionCreated(final RenderExtension renderExtension_) {
        _glRenderer = new GLRenderer(renderExtension_);
        _customSurfaceView = new CustomSurfaceView(getApplicationContext(), _glRenderer);
        _driver = new Driver(_customSurfaceView, 30);
        //setContentView(_customSurfaceView);
        FrameLayout viewHolder = new FrameLayout(getApplicationContext());
        viewHolder.addView(_customSurfaceView);
        View view= LayoutInflater.from(this).inflate(R.layout.activity_barcode_plugin,viewHolder,false);
        viewHolder.addView(view);
        setContentView(viewHolder);
    }

目标已确认我正试图这样做..

@Override
    public void onTargetRecognized(final Tracker tracker_, final String targetName_) {
        Log.i(TAG, "Thread Name is" + Thread.currentThread().getName());
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                VideoView videoView = (VideoView) findViewById(R.id.videoView);
                android.widget.MediaController mediaController = new android.widget.MediaController(BarcodePluginActivity.this);
                videoView.setMediaController(mediaController);
                String fileName = "android.resource://" + getPackageName() + "/" + R.raw.javavideotutorial;
                Uri uri = Uri.parse(fileName);
                videoView.setVideoURI(uri);
                videoView.start();
            }
        });
    }

视频正在播放但是它没有在相机的表面上显示。当在onTargetRecognized方法我正在做服装表面视图隐形/消失视频显示但我希望它显示在相机预览...如何克服这个问题???请帮助我..我正在使用Wikitude SDK,Android Native Api和在Android Studio上运行代码。 这是我的布局......

这是我的布局..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
    android:background="@android:color/holo_blue_bright"
    android:id="@+id/lin">
    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/barcode_plugin_info_field"
        android:editable="false"
        android:background="@color/wikitude_orange_light"
        android:visibility="gone"
        android:text="@string/barcode_hint"
        android:gravity="center_horizontal"
        android:padding="5dp"
        />
    <VideoView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:id="@+id/videoView"
        android:layout_gravity="center"
        />
    </FrameLayout>
</LinearLayout>

我正在播放Video On Video View。请不要为编辑文本而烦恼。

1 个答案:

答案 0 :(得分:1)

这是因为CustomSurfaceView和VideoView都是SurfaceViews。 SurfaceView是一种特殊类型的视图,其行为与任何其他视图不同。

现在,您的VideoView get会在CustomSurfaceView下面呈现。在“onRenderExtensionCreated()”方法中添加视图时,添加以下调用:

videoView.setZOrderMediaOverlay(true);