使用 Google Cardboard 制作 VR 视频播放器

Making a VR video player using Google Cardboard

如何使用 Google CardBoard Android SDK 制作一个简单的 VR 视频播放器?我是这个领域的新人。我正在尝试更改 github 中的程序以立即播放纸板视频!

我使用 Rajawali 库以及 Google Cardboard Sdk 和修改后的 initscene() 以这种方式完成这项工作。

public class VideoRenderer extends RajawaliCardboardRenderer {

Context mContext;

private MediaPlayer mMediaPlayer;
private StreamingTexture mVideoTexture;

public VideoRenderer(Context context) {
    super(context);
    mContext = context;
}

@Override
protected void initScene() {

    mMediaPlayer = MediaPlayer.create(getContext(),
            R.raw.video);
    mMediaPlayer.setLooping(true);

    mVideoTexture = new StreamingTexture("sintelTrailer", mMediaPlayer);
    Material material = new Material();
    material.setColorInfluence(0);
    try {
        material.addTexture(mVideoTexture);
    } catch (ATexture.TextureException e) {
        e.printStackTrace();
    }

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

    getCurrentScene().addChild(sphere);

    getCurrentCamera().setPosition(Vector3.ZERO);

    getCurrentCamera().setFieldOfView(75);

    mMediaPlayer.start();

}

@Override
protected void onRender(long ellapsedRealtime, double deltaTime) {
    super.onRender(ellapsedRealtime, deltaTime);
    mVideoTexture.update();
}

@Override
public void onPause() {
    super.onPause();
    if (mMediaPlayer != null)
        mMediaPlayer.pause();
}

@Override
public void onResume() {
    super.onResume();
    if (mMediaPlayer != null)
        mMediaPlayer.start();
}

@Override
public void onRenderSurfaceDestroyed(SurfaceTexture surfaceTexture) {
    super.onRenderSurfaceDestroyed(surfaceTexture);
    mMediaPlayer.stop();
    mMediaPlayer.release();
}
 }