ST Video Player
A video screen that plays in time for everyone. Play, pause, stop and jumps from any player reach everyone in the room, and players who join later start at the right moment. Add it with Add Component → StageTime → ST Video Player; Unity adds a Video Player next to it.
Set up the Video Player as usual:
- Render Mode: Material Override (pick the screen's renderer; for URP materials the property is
_BaseMap) or Render Texture. Modes that draw over the camera are not allowed. - Audio Output Mode: Audio Source (pick an Audio Source for 3D sound; add an ST Spatial Audio Source to it for spatial sound) or Direct.
- Leave Source empty or set a Video Clip. Links go in the ST Video Player (below). StageTime turns off Play On Awake: the ST Video Player decides what plays.
| Field | |
|---|---|
url | Direct link to a video file, for example https://example.com/video.mp4. Play() and Auto Play use it. Empty = the Video Player's clip |
syncMode | Sync or Sync To Requester (below) |
requesterDelay | Sync To Requester only: seconds everyone else plays behind the requester (default 0.3) |
autoPlay | Start playing when the world loads |
loop | Start again from the beginning at the end |
For now only direct links to .mp4 files (https only, up to 256 characters) play. Streaming pages such as
YouTube do not. Use https: Android headsets block plain http.
Sync modes
Sync — everyone sees the same frame at the same moment. Use it for watching together, music videos, trailers.
Sync To Requester — the player who pressed play (or last paused, resumed or jumped) is the clock. Everyone else
plays requesterDelay seconds behind them. Other players hear the requester's voice a little late, so this keeps the
video in time with what they hear: use it for karaoke and sing-alongs. The requester's own video never jumps.
Players that drift more than about 0.12 seconds are corrected with a jump. A new video starts when the requester's player has loaded it, so the requester never misses the beginning (anyone else who is still loading catches up).
From scripts
STVideoPlayer video = GetComponent<STVideoPlayer>();
video.PlayURL("https://example.com/song.mp4"); // load and play a link for everyone
video.Pause();
video.Play(); // resume, or play the last link again
video.SetTime(video.time + 10f); // jump for everyone
video.Stop();
| Member | |
|---|---|
PlayURL(string) | Loads a direct .mp4 link and plays it for everyone |
Play() | Resumes a paused video, or plays the last link (or url, or the clip) again |
Pause(), Stop() | Pause or stop for everyone |
SetTime(float) | Jump to a position in seconds, for everyone |
isPlaying, isPaused | Current state |
time, duration | Position and length in seconds on this device (duration is 0 until loaded) |
currentUrl | The loaded link ("" for the clip) |
requester | The player who started or last controlled the video |
Any player can control the video: decide in your script who may press the buttons. syncMode is read when a video
is loaded, so set it on every device (for example from a synced variable) before calling PlayURL.
Scripts on the same GameObject get these events:
| Event | When | Runs on |
|---|---|---|
OnVideoStart() | A newly loaded video started | everyone |
OnVideoPlay() / OnVideoPause() | The video resumed / paused | everyone |
OnVideoEnd() | A video that doesn't loop finished | each device, as it finishes |
OnVideoError() | The video could not be loaded or played | each device that failed |
See the video controls example.
Local preview
Pressing Play in your project plays the video locally (one player, no sync), so you can check the screen and sound. Test sync with Build & Test.