Roblox UtilitiesDevlHub Roblox Documentation

Class

VideoPlayer

NotBrowsable
Inherits
Instance › Object
Memory category
Instances

Used to play video assets.

An instance for playing video assets. It can be connected to a VideoDisplay via a Wire to show the video and can be connected to audio instances via a Wire to play the audio track.

Properties 12#

AutoLoadInStudiobooleanLoads the VideoContent while in Studio Edit mode.Write: RobloxScriptSecurityReadSafeNotReplicatedNotScriptable
AutoPlayInStudiobooleanPlays the VideoContent while in Studio Edit mode.Write: RobloxScriptSecurityReadSafeNotReplicatedNotScriptable
IsLoadedbooleanIndicates when the VideoContent has loaded and is ready to play.ReadSafeReadOnlyNotReplicated
IsPlayingbooleanDenotes whether this VideoPlayer is currently playing.ReadSafeReadOnlyNotReplicated
LoopingbooleanControls whether this VideoPlayer loops.ReadSafe
MaximumResolutionVideoSampleSizeCaps the resolution of decoded video frames for this VideoPlayer.ReadSafeHidden
PlaybackSpeedfloatControls the speed at which the video is played.ReadSafe
ResolutionVector2Gets the original source resolution of the VideoContent file.ReadSafeReadOnlyNotReplicated
TimeLengthdoubleIndicates the length of the VideoContent in seconds.ReadSafeReadOnlyNotReplicated
TimePositiondoubleIndicates the progress in seconds of the VideoContent.ReadSafe
VideoContentContentThe asset to be loaded into the VideoPlayer.ReadSafe
VolumefloatControls how loudly the audio track will be played.ReadSafe

AutoLoadInStudio: boolean#

NotReplicatedNotScriptableWrite: RobloxScriptSecurityReadSafe

By default, VideoContent does not load while in Studio Edit mode and shows no output when wired to VideoDisplay to reduce studio memory usage. Toggle this option to load VideoContent while in Studio Edit mode.

AutoPlayInStudio: boolean#

NotReplicatedNotScriptableWrite: RobloxScriptSecurityReadSafe

Plays the VideoContent while in Studio Edit mode. AutoLoadInStudio must be on for this option to show.

IsLoaded: boolean#

ReadOnlyNotReplicatedReadSafe

This property is true when the VideoContent has loaded and is ready to play.

IsPlaying: boolean#

ReadOnlyNotReplicatedReadSafe

Denotes whether this VideoPlayer is currently playing. This property is read-only, but replicates. To play and pause a VideoPlayer at runtime, use the Play() and Pause() methods.

Looping: boolean#

ReadSafe

Controls whether this VideoPlayer loops after reaching the end of its TimeLength.

MaximumResolution: VideoSampleSize#

HiddenReadSafe

The maximum resolution, as an VideoSampleSize value, that the video decoder produces when playing this VideoPlayer. Defaults to VideoSampleSize.Full, which doesn't limit the decoded resolution. Lower VideoSampleSize values reduce the resolution the decoder outputs, which can lower memory usage on constrained devices.

PlaybackSpeed: float#

ReadSafe

Multiplier that controls how quickly the video plays, directly controlling the perceived pitch of the audio track. Ranges from 0 to 1.

Resolution: Vector2#

ReadOnlyNotReplicatedReadSafe

This property gets the original source resolution of the VideoContent file.

TimeLength: double#

ReadOnlyNotReplicatedReadSafe

This property indicates the length of the VideoContent in seconds. If the video is not loaded, this value is 0.

TimePosition: double#

ReadSafe

This property indicates the progress in seconds of the VideoContent. It can be changed to move the playback position of the video both before and during playback.

VideoContent: Content#

ReadSafe

The content ID of the video file a VideoPlayer object is associated with. To save resources and improve performance, call the Unload() method to unload the VideoContent when the VideoPlayer is not visible or in use.

Volume: float#

ReadSafe

Volume level, which is multiplied onto the output audio stream, controlling how loudly the audio track plays. Ranges from 0 to 3.

Methods 7#

GetConnectedWiresReturns an array of Wires that are connected to the specified pin.
GetInputPinsGets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.
GetOutputPinsGets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.
LoadAsyncLoads the VideoContent before it is played.Yields
PausePauses the VideoPlayer wherever its TimePosition is.
PlayPlays the VideoPlayer from wherever its TimePosition is.
UnloadUnloads the VideoPlayer.VideoContent to save resources.

GetConnectedWires(pin: string): List<Wire>#

Returns an array of Wires that are connected to the specified pin. VideoPlayer has one "Output" pin.

NameTypeDefaultDescription
pinstringAn input or output pin on this instance
Returns
  • List<Wire> — An array of Wires

GetInputPins(): Array#

Gets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.

For VideoPlayer, there are none.

Returns
  • Array — An array of strings representing valid pin names.

GetOutputPins(): Array#

Gets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.

For VideoPlayer, this is Output only.

Returns
  • Array — An array of strings representing valid pin names.

LoadAsync(): AssetFetchStatus#

Yields

VideoContent is typically only loaded when Play() is called, causing some buffering delay. This function can preload VideoContent so that it can be immediately played when Play() is called. Loading videos can consume a significant amount of device memory.

Returns

Pause(): ()#

Pauses the VideoPlayer wherever its TimePosition is. Replicates from server to client.

Returns
  • ()

Play(): ()#

Plays the VideoPlayer from wherever its TimePosition is. Replicates from server to client. To save resources and improve performance, call the Unload() method to unload the VideoContent when the VideoPlayer is not visible or in use.

Returns
  • ()

Unload(): ()#

Unloads the VideoContent to save resources. After calling this method, the IsLoaded property is false, and the TimePosition resets to 0. To play the video again, the LoadAsync() or Play() method must be called to reload the video.

Returns
  • ()

Events 4#

DidEndFires when the VideoContent has completed playback and stopped.
DidLoopFires when the VideoContent loops.
PlayFailedFires when the VideoPlayer fails to load or play its VideoContent.
WiringChangedFires when another instance is connected to or disconnected from the VideoPlayer via a Wire.

DidEnd()#

Fires after the VideoPlayer has completed playback and stopped. Note this event does not fire for videos with Looped set to true since it continues playing upon reaching its end. This event also does not fire when the video is stopped before playback has completed; for this, use VideoPlayer:GetPropertyChangedSignal() on the IsPlaying property.

DidLoop()#

Event that fires after the VideoPlayer loops. This happens when the video reaches the end of its content. This event does not fire if the video is looped manually by changing its TimePosition.

PlayFailed(error: AssetFetchStatus)#

Fires when the VideoPlayer fails to load or play its VideoContent. The error parameter is an AssetFetchStatus value that describes why the content couldn't be fetched.

NameTypeDefaultDescription
errorAssetFetchStatusAn AssetFetchStatus value describing why the VideoContent failed to load.

WiringChanged(connected: boolean, pin: string, wire: Wire, instance: Instance)#

Event that fires after a Wire becomes connected or disconnected, and that Wire is now or was previously connected to a pin on the VideoPlayer and to some other wirable instance.

NameTypeDefaultDescription
connectedbooleanWhether the instance was connected or disconnected.
pinstringThe pin on the VideoPlayer that the Wire targets.
wireWireThe Wire between the VideoPlayer and the other instance.
instanceInstanceThe other instance that is or was connected through the Wire.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed