In January of this year Unity released a sample project with the purpose of creating an interactive video VR experience. This sample projects contains a menu through which the user can go to different scenes which each have a video player object with a 360 video file that starts playing on entering the scene.

Problem

However, once the user clicks on one of the items in the menu a loading screen appears before the scene loads. I am creating an experience where users can interact with objects in the 360 video. For example, in my 360 video there is a door. If the user gazes at the door, it opens. To make this I have two video files: in front of door and open door. open door follows after in front of door if the user gazes at the door in in front of door. To make the experience as real as possible the transition between the videos should be seamless. Therefore, a loading screen is not an option.

Interactive Door

In the sample project the scenes have videoplayers. These video players have the wait for first frame option turned on. After the video has been loaded (we are not talking about buffering as the video file is already on the system) the loading screen disappears. To achieve a seamless transition the first thing I’ve tried is switching the option wait for first frame off. This resulted in a near seamless transition in the Unity editor. However, when I deployed to my Oculus Go I noticed a short freeze of the first video before starting the second video. Conlclusion: although this is the format Unity provides, switching scene’s is not an option.

Solution

A solution to this problem, instead of switching scenes, is to switch between video players in the same scene. Once the user gazes at the door the videoplayer containing the open door video is enabled and starts playing and the videoplayer containing the in front of door video stops. Notice that the second video player should start playing before the first one stops - and not the other way around. To make this work you have to prepare the open door video before the user gazes at the door by calling Prepare() on the videoplayer. This inits the video and when the user then gazes at the door in in front of door the open door video starts playing instantly.

Example in C#

public class Hotspot : MonoBehaviour {

  public VideoPlayer videoPlayer1;
  public VideoPlayer videoPlayer2;

  void Start(){
    videoPlayer2.Prepare();
  }

  void OnGaze(){
    StartPlayer2();
    StopPlayer1();
  }

  void StopPlayer1(){
    videoPlayer1.Stop();
    videoPlayer2.SetActive(false);
  }

  void StartPlayer2(){
    videoPlayer2.SetActive(true);
    videoPlayer2.Play();
  }
}