VideoFrame

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

一个 VideoFrame 会像 Frame 那样渲染一个长方形,但是会移动的视频图像。视频必须是从 Roblox 网站上传的文件。

视频会按照整个长方体的大小进行调整,但在其 native 分辨率下显示时会最佳。

2D 和 3D 声音

一个 VideoFrame 放置在 SurfaceGui 下,在 BasePart 上发出声音从该部分的 BasePart.Position 发出声音。

一个 VideoFrame 展示 Doppler 效果,意味着它的频率和 pitch 与它所附加到的任何部分的相对运动变化。

视频框架的音量将由客户端的音频听取器(默认为 Camera 位置)和视频框架的部分位置决定。

如果在基地部件上放置 VideoFrame ,它将被视为 “全球” ,如果它不是在 SurfaceGui 下面放置在基地部件上。在这种情况下,声音将在整个场景方播放在同一的音量。

代码示例

The code sample below demonstrates how to create and play a VideoFrame with SomeValidAssetID once the video has loaded.

Creating and Playing a Video

local screenPart = Instance.new("Part")
screenPart.Parent = workspace
local surfaceGui = Instance.new("SurfaceGui")
surfaceGui.Parent = screenPart
local videoFrame = Instance.new("VideoFrame")
videoFrame.Parent = surfaceGui
videoFrame.Looped = true
videoFrame.Video = "rbxassetid://" -- add an asset ID to this
while not videoFrame.IsLoaded do
task.wait()
end
videoFrame:Play()

概要

属性

继承自GuiObject属性继承自GuiBase2d属性

方法

继承自GuiObject方法

活动

继承自GuiObject活动继承自GuiBase2d活动

属性

IsLoaded

只读
未复制
读取并联

VideoFrame.Video 从 Roblox 服务器加载时,该属性将是真的,因为它已准备好播游玩。

Looped

读取并联

此属性设置是否重播 VideoFrame.Video 在播放完成后重播一次。

Playing

未复制
读取并联

此属性表示 VideoFrame.Video 是否正在播放。它可以设置为开始或暂停播放作为 VideoFrame:Play()VideoFrame:Pause() 功能的替代。

Resolution

只读
未复制
读取并联

此属性获得 VideoFrame.Video 文件的原始视频解析度。

TimeLength

只读
未复制
读取并联

此属性表示在秒数内 VideoFrame.Video 的长度。如果视频未加载,此值将为 0。

TimePosition

未复制
读取并联

此属性表示在 VideoFrame.Video 的秒进度。它可以改变以在播放时移动视频的播放位置。

Video

ContentId
读取并联

视频文件的内容ID与VideoFrame对象关联。

代码示例

The code sample below demonstrates how to create and play a VideoFrame with SomeValidAssetID once the video has loaded.

Creating and Playing a Video

local screenPart = Instance.new("Part")
screenPart.Parent = workspace
local surfaceGui = Instance.new("SurfaceGui")
surfaceGui.Parent = screenPart
local videoFrame = Instance.new("VideoFrame")
videoFrame.Parent = surfaceGui
videoFrame.Looped = true
videoFrame.Video = "rbxassetid://" -- add an asset ID to this
while not videoFrame.IsLoaded do
task.wait()
end
videoFrame:Play()

Volume

读取并联

此属性决定VideoFrame.Video的播放返回音。可以设置它在 0 和 100 之间的数字。

方法

Pause

void

VideoFrame.Playing 设置为 false,如果 VideoFrame.Video 正在播放,则会暂停播放。

VideoFrame.TimePosition 不是重置时,当视频恢复时,它将从其前一位置继续。


返回

void

Play

void

VideoFrame.Playing 设置为 true,这将播放 VideoFrame.Video,继续从当前的 VideoFrame.TimePosition .


返回

void

代码示例

The code sample below demonstrates how to create and play a VideoFrame with SomeValidAssetID once the video has loaded.

Creating and Playing a Video

local screenPart = Instance.new("Part")
screenPart.Parent = workspace
local surfaceGui = Instance.new("SurfaceGui")
surfaceGui.Parent = screenPart
local videoFrame = Instance.new("VideoFrame")
videoFrame.Parent = surfaceGui
videoFrame.Looped = true
videoFrame.Video = "rbxassetid://" -- add an asset ID to this
while not videoFrame.IsLoaded do
task.wait()
end
videoFrame:Play()

活动

DidLoop

一个发生在 VideoFrame.Video 循环发生时触发的事件。返回视频的内容 ID。

参数

video: string

循环的视频的内容 ID。


Ended

此事件触发,当 VideoFrame.Video 完成播放并停止。

参数

video: string

暂停结束后的内容ID。


Loaded

此事件发生,当 VideoFrame.Video 已加载。

参数

video: string

加载视频的内容ID。


Paused

此事件触发,当 VideoFrame.Video 暂停使用 VideoFrame:Pause() 或设置 VideoFrame.Playing 为 false 时。

参数

video: string

暂停视频的内容ID。


Played

这个事件触发,当 VideoFrame.Video 使用 VideoFrame:Play() 函数或设置 VideoFrame.Playing 为真。

参数

video: string

播放视频的内容ID。