Example 6 - Video Player
This Example sets up a remote video to play on three screens. The following instrcuctions will guide you through the set up of doing this in your scene.
  1. 1.
    Create a Primitive in your scene; Cube, sphere, plane. For the example we have used Plane so you can see the Video, otherwise it wraps it around the object. You may also need to rotate the object so the video is the correct way around.
  2. 2.
    Add an onStart trigger. To this trigger, add an Action and add the Action, Place Video on Object. This links the Video to that Game Object. (We make this a two step process for when there are multiple videos in the scene.)
The Video can be local (must be in your project folder and in a resource folder if you want it included in your build), or remote streaming (must be a fully qualified address). You can use the clip shown above for a test. Also note that Unity only supports certain formats on certain devices. https://docs.unity3d.com/ScriptReference/Video.VideoPlayer.html I often use .ogg files as this is native to Unity, but .mp4 and .mov work great.
Note: YouTube is NOT a video format.
3. Add a trigger to your scene to play the Video. This could be onkeydown on onplayerenter, or whatever is required. Add an Action to this trigger to play the video.
Here you must add the Object (primitive with Video) again, in this case it is on Plane. This is done this way for multiple videos. Make whatever adjustments you want for start frame, looping, and Audio..
4. You can also add trigger/Action to stop or pause the video. If you pause it, then trigger play again, it will continue. If you stop and trigger play, it will start again.
5. You can also remove the video from the Object, and it is highly recommended to do this before you add it again or add another to the same object.
Last modified 1yr ago
Copy link