1

I'm working with the Google VR SDK for Unity trying to build a simple 360 Video viewer using the components that come with the SDK. I'm trying to extend their PanoVideoSample to dynamically change the source video when the user navigates from a menu.

I'm having trouble changing the URL for the GvrVideoPlayerTexture via code. In their demo scene (VideoDemo) they have a PanoVideoSample that contains a Video Sphere, which you can edit the GVRVideoPlayerTexture script in the inspector panel to point at the proper video URL.

I'd like to dynamically set the video URL in C# rather than hard-code a bunch of individual video spheres then hide/show them. I've almost got this working with the following code.

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

}

The code above seems to work, but the problem is the texture on the videoSphere turns white after the url is set and the texture is re-initialized. I can see that the new video loads and I can hear the audio for the new video, but the scene just shows a white texture. See the output here

I'm wondering if I'm missing a key step on the GvrVideoPlayerTexture or perhaps additional calls to update the StereoPanoSphereMaterial that is used to render the scene. This SDK is pretty new and there doesn't seem to be many people writing about it, so any help is appreciated.

abdul
  • 1,562
  • 1
  • 17
  • 22
eklimcz
  • 31
  • 2

1 Answers1

0

I eventually found the answer to my question in the documentation on the Google VR docs (Streaming Video Support). I'm still not totally clear what I was doing wrong in my first attempt, but this is the code that worked for me.

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 ();
eklimcz
  • 31
  • 2