首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌VR软件开发工具包(Unity) - GvrVideoPlayerTexture交换地址

谷歌VR软件开发工具包(Unity) - GvrVideoPlayerTexture交换地址
EN

Stack Overflow用户
提问于 2017-01-24 03:43:26
回答 1查看 415关注 0票数 1

我正在与Google VR SDK for Unity合作,试图使用开发工具包附带的组件来构建一个简单的360视频查看器。我正在尝试扩展他们的PanoVideoSample,当用户从菜单导航时,可以动态改变源视频。

我在通过代码更改GvrVideoPlayerTexture的网址时遇到了问题。在他们的演示场景(VideoDemo)中,他们有一个包含Video Sphere的PanoVideoSample,您可以编辑检查器面板中的GVRVideoPlayerTexture脚本以指向正确的视频URL。

我想在C#中动态设置视频地址,而不是硬编码一堆单独的视频球体,然后隐藏/显示它们。使用下面的代码,我几乎已经完成了这项工作。

代码语言:javascript
复制
public void SwapVideo(int index){

    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoURL = urls [index];// my new url 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().ReInitializeVideo ();
    videoSphere.SetActive (true);

}

public void ReturnToMainMenu(){

    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().CleanupVideo();
    videoSphere.SetActive (false);

    this.gameObject.SetActive (true);

}

上面的代码似乎可以工作,但问题是在设置url并重新初始化纹理后,videoSphere上的纹理变为白色。我可以看到新的视频加载,我可以听到新视频的音频,但场景只显示白色纹理。See the output here

我想知道我是否遗漏了GvrVideoPlayerTexture上的一个关键步骤,或者可能是用于更新用于渲染场景的StereoPanoSphereMaterial的额外调用。这是一个非常新的SDK,似乎没有多少人在写它,所以任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2017-02-02 02:38:35

我最终在谷歌VR文档(Streaming Video Support)上找到了我问题的答案。我仍然不完全清楚我在第一次尝试中做错了什么,但这是为我工作的代码。

代码语言:javascript
复制
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoURL = urls [index];
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoType = GvrVideoPlayerTexture.VideoType.Other;
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoProviderId = string.Empty;
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoContentID = string.Empty;
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().CleanupVideo ();
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().ReInitializeVideo ();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41814328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档