How to make a simple VR video player by Google CardBoard Android SDK

ぐ巨炮叔叔 提交于 2019-12-09 06:52:28

问题


Im following as what Mog suggest in the post:

How to create VR Video player using Google Cardboard SDK for Unity

Here's my code snippet

1. In the MainActivity's onSurfaceCreated() method , I initialise a texture and bind it to GL, and create a surface and a mediaplayer associated to them.

  1. in the onNewFrame() method, I update the texture as what Mog said in the post

I saved my short video as small.mp4 in the raw folder, however , after I start my app the two sides are blank, and the video's sound is actually playing.


回答1:


I was facing a similar problem in order to get this done I've used the great RajawaliVR library.

The code I used:

    streamingTexture = new StreamingTexture("video", mediaPlayer);
    Material material = new Material();
    material.setColor(0);

    try {
        material.addTexture(texture);
    } catch (ATexture.TextureException e) {
        throw new RuntimeException(e);
    }

    Sphere sphere = new Sphere(50, 64, 32);
    sphere.setScaleX(-1);
    sphere.setMaterial(material);
    getCurrentScene().addChild(sphere);


来源:https://stackoverflow.com/questions/31945630/how-to-make-a-simple-vr-video-player-by-google-cardboard-android-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!