Televisions and video
Since SDK 0.2.1
A world shows a video in two ways:
| A clip included in the world | A video from the internet | |
|---|---|---|
| How | Unity's Video Player component with a Video Clip of your project | An FL# script with a VideoPlayer (video players) |
| What it plays | The clip, which goes into the world's files | An address: a video file, a stream, the page of a video site |
| Together | Each player's game plays it from its own start | Your script keeps everyone at the same moment |
| Asked to the player | Nothing | The first video of a site, except on the big video sites |
A Video Player that reads a URL is removed from the world: videos from the internet go through FL# (what a world may hold).
A screen everyone watches
The Television of the example world is a complete screen: a player types an address (or a YouTube link) and presses Play / Pause, and everyone sees the same video at the same moment, players who arrive later included.
To put it in your world:
- Import the Example World sample (install the SDK) and copy
Flux/Television.csinto your FL# scripts folder, then add it to Flux Sharp Sources of your NW World Config. - Make the screen: an object whose material shows the picture (with URP's Lit, its texture property is
_BaseMap). - Put an Audio Source at the screen, for the sound: 3D (Spatial Blend at 1) so it comes from the screen.
- Make a World Space canvas next to it with an Input Field, a Button and a Text (UI).
- On an object, Add Component, NodeWorld, FL# Script, pick
NodeWorldExample.Television, give it a Network Id, and set its fields:
| Field | |
|---|---|
screen | The screen's material. |
textureProperty | The texture property the picture goes into (_BaseMap). |
speaker | The Audio Source. |
address | The Input Field: Enter plays the address for everyone. |
playPause | The Button. |
status | The Text: loading, playing, paused, or why it cannot play. |
resyncThreshold | Seconds a player's video may drift before it jumps back to the shared time (1.5). |
The player who acts takes the television's ownership and sends the address, playing or paused, and where the video stands at a time of the server's clock; each game plays the video itself and follows that time.
What the players see
- The first video of a site asks each player for permission, in a window: Always, This time or Deny (sites a world contacts). The big video sites (YouTube, Twitch, Vimeo…) play without asking, unless the player changed that list. Meanwhile the video is loading.
- The game turns the page of a video site into its video. A private video, one blocked in the player's region, or one that needs to sign in, does not play (
VideoError.AccessDenied). - The video player ships with the game on Windows, Linux and Quest. In Play mode, every address plays without a window.
