Skip to main content

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
urlDirect link to a video file, for example https://example.com/video.mp4. Play() and Auto Play use it. Empty = the Video Player's clip
syncModeSync or Sync To Requester (below)
requesterDelaySync To Requester only: seconds everyone else plays behind the requester (default 0.3)
controlAccessEveryone, or Hosts And Moderators: only room hosts and moderators can play, pause, stop and seek
autoPlayStart playing when the world loads
loopStart again from the beginning at the end
Links

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.

Approved sources are coming

In a future SDK update, ST Video Player will only load from an approved list of sources, and links to other sites will stop loading. The list will be published in these docs before the change. See the Roadmap.

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 sing-alongs and performances. 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/video.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 (including the player who pressed it)
isPlaying, isPausedCurrent state
time, durationPosition and length in seconds on this device (duration is 0 until loaded)
currentUrlThe loaded link ("" for the clip)
requesterThe player who started or last controlled the video
canControlThe local player may control the video (see controlAccess)

With controlAccess set to Everyone, any player can control the video: decide in your script who may press the buttons. With Hosts And Moderators, StageTime ignores everyone else's controls. To play an ST Queue, see playing a queue on a video player. 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:

EventWhenRuns on
OnVideoStart()A newly loaded video startedeveryone
OnVideoPlay() / OnVideoPause()The video resumed / pausedeveryone
OnVideoEnd()A video that doesn't loop finishedeach device, as it finishes
OnVideoError()The video could not be loaded or playedeach device that failed

OnVideoEnd and OnVideoError are only raised for the video that is loaded now, never for one that was replaced, so you can safely start the next video from them. A link that the server refuses (for example a 403) raises OnVideoError.

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.