android - 如何通过Google CardBoard Android SDK制作一个简单的VR视频播放器

标签 android android-mediaplayer google-cardboard

我按照 Mog 在帖子中的建议进行操作:

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

这是我的代码 fragment

1. 在 MainActivity 的 onSurfaceCreated() 方法中,我初始化了一个纹理并将其绑定(bind)到 GL,并创建了一个表面和一个与之关联的媒体播放器。

enter image description here

  1. onNewFrame() 方法中,我按照 Mog 在帖子中所说的更新纹理

enter image description here

我把我的短视频保存为 raw 文件夹中的 small.mp4,但是,当我启动我的应用程序后,两边都是空白的,而视频的声音正在播放。

最佳答案

为了完成这项工作,我遇到了类似的问题,我使用了很棒的 RajawaliVR library .

我使用的代码:

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

关于android - 如何通过Google CardBoard Android SDK制作一个简单的VR视频播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31945630/

相关文章:

android - 如何从 android kotlin 协程获取结果到 UI 线程

android - Release模式下不显示广告

Android:GridView 在滚动时显示重复的图像

Java NullPointerException 获取资源

android - VideoView 在不可见时不启动

xcode - 从 Unity 导入的 Xcode 项目中库名称拼写错误

android - 对齐 EditText inputType=textPassword 中的提示文本,用于从右到左 (RTL) 语言

android - 在非 Activity 类中使​​用 MediaPlayer

android - CardboardActivity 中的内存泄漏

c# - 在 Unity3d 中为 VR 360 度图像应用更改聚焦球体的 Material