VideoFrame

Show Deprecated

A VideoFrame renders a rectangle, like a Frame does, with a moving video image. The video must be from a file uploaded to the Roblox website.

The video is scaled to fit the entirety of the rectangle, but looks best when displayed at its native resolution.

2D and 3D Sound

A VideoFrame placed underneath SurfaceGui on a BasePart will emit its sound from that part's BasePart.Position.

A VideoFrame exhibits the Doppler effect, meaning its frequency and pitch varies with the relative motion of whatever part it is attached to.

The volume of the VideoFrame will be determined by the distance between the client's sound listener (by default the Camera position) and the position of the VideoFrame's part.

A VideoFrame is considered "global" if it is not placed underneath SurfaceGui on a BasePart. In this case, the sound will play at the same volume throughout the entire place.

Code Samples

Creating and Playing a Video

1local screenPart = Instance.new("Part")
2screenPart.Parent = workspace
3
4local surfaceGui = Instance.new("SurfaceGui")
5surfaceGui.Parent = screenPart
6
7local videoFrame = Instance.new("VideoFrame")
8videoFrame.Parent = surfaceGui
9
10videoFrame.Looped = true
11videoFrame.Video = "rbxassetid://" -- add an asset ID to this
12
13while not videoFrame.IsLoaded do
14 task.wait()
15end
16
17videoFrame:Play()

Summary

Properties

Indicates when the VideoFrame.Video has loaded from Roblox servers and is ready to play.

READ ONLY
NOT REPLICATED

Sets whether or not the VideoFrame.Video repeats once it has finished when it is playing.

Indicates whether the VideoFrame.Video is currently playing. It can be set to start or pause playback.

NOT REPLICATED

Gets the original source resolution of the VideoFrame.Video file.

READ ONLY
NOT REPLICATED

Indicates the length of the VideoFrame.Video in seconds.

READ ONLY
NOT REPLICATED

Indicates the progress in seconds of the VideoFrame.Video.

NOT REPLICATED

The content ID of the video file a VideoFrame object is associated with.

Indicates how loud the VideoFrame.Video is currently playing back.

Events


Fires whenever the VideoFrame.Video loops.


Fires when the VideoFrame.Video has completed playback and stopped.


Fires when the VideoFrame.Video is loaded.


This event fires whenever the VideoFrame.Video is paused using VideoFrame:Pause() or by setting VideoFrame.Playing to false.


Fires whenever the VideoFrame.Video is played using the VideoFrame:Play() function or by setting VideoFrame.Playing to true.

Methods

Pause(): void  

Sets VideoFrame.Playing to false, pausing playback if the VideoFrame.Video is playing.

Play(): void  

Sets VideoFrame.Playing to true, playing the VideoFrame.Video from the current VideoFrame.TimePosition.

Properties

IsLoaded

Read Only
Not Replicated

This property will be true when the VideoFrame.Video has loaded from Roblox servers and is ready to play.

Looped

This property sets whether or not the VideoFrame.Video repeats once it has finished when it is playing.

Playing

Not Replicated

This property indicates whether the VideoFrame.Video is currently playing. It can be set to start or pause playback as an alternative to the VideoFrame:Play() and VideoFrame:Pause() functions.

Resolution

Read Only
Not Replicated

This property gets the original source resolution of the VideoFrame.Video file.

TimeLength

Read Only
Not Replicated

This property indicates the length of the VideoFrame.Video in seconds. If the video is not loaded, this value will be 0.

TimePosition

Not Replicated

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

Video

The content ID of the video file a VideoFrame object is associated with.

Volume

This property determines how loud the VideoFrame.Video plays back. It can be set to a number between 0 and 100.

Events

DidLoop

An event that fires whenever the VideoFrame.Video loops. Returns the content ID of the video.

Parameters

video: string

The content ID of the video that looped.


Ended

This event fires when the VideoFrame.Video has completed playback and stopped.

Parameters

video: string

The content ID of the paused that ended.


Loaded

This event fires when the VideoFrame.Video is loaded.

Parameters

video: string

The content ID of the loaded video.


Paused

This event fires whenever the VideoFrame.Video is paused using VideoFrame:Pause() or by setting VideoFrame.Playing to false.

Parameters

video: string

The content ID of the paused video.


Played

This event fires whenever the VideoFrame.Video is played using the VideoFrame:Play() function or by setting VideoFrame.Playing to true.

Parameters

video: string

The content ID of the played video.


Methods

Pause

void

Sets VideoFrame.Playing to false, pausing playback if the VideoFrame.Video is playing.

As VideoFrame.TimePosition is not reset, when the video is resumed it will continue from its previous position.


Returns

void

No return.

Play

void

Sets VideoFrame.Playing to true, This plays the VideoFrame.Video, continuing from the current VideoFrame.TimePosition.


Returns

void

No return.

Code Samples

Creating and Playing a Video

1local screenPart = Instance.new("Part")
2screenPart.Parent = workspace
3
4local surfaceGui = Instance.new("SurfaceGui")
5surfaceGui.Parent = screenPart
6
7local videoFrame = Instance.new("VideoFrame")
8videoFrame.Parent = surfaceGui
9
10videoFrame.Looped = true
11videoFrame.Video = "rbxassetid://" -- add an asset ID to this
12
13while not videoFrame.IsLoaded do
14 task.wait()
15end
16
17videoFrame:Play()