เรียนรู้
Engine Class
VideoPlayer
ไม่สามารถเรียกดู

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
สมาชิกที่ได้รับทอด
ตัวอย่างโค้ด
ผู้เล่นวิดีโอ (เซิร์ฟเวอร์)
-- สิ่งนี้ควรอยู่ใน "Script" ที่มี RunContext ตั้งค่าเป็น "Legacy" หรือ "Server"
-- สร้างสิ่งที่วิดีโอแสดงผลไว้
local videoScreenPart = Instance.new("Part")
videoScreenPart.Anchored = true
videoScreenPart.Size = Vector3.new(12, 6, 1)
videoScreenPart.CFrame = CFrame.new(0, 5, 0)
videoScreenPart.Parent = workspace
local videoScreenUI = Instance.new("SurfaceGui")
videoScreenUI.Parent = videoScreenPart
local videoDisplay = Instance.new("VideoDisplay")
videoDisplay.Size = UDim2.new(1, 0, 1, 0)
videoDisplay.Parent = videoScreenUI
-- สร้างสถานที่ที่แหล่งวิดีโอเริ่มต้น
local videoSource = Instance.new("VideoPlayer")
videoSource.VideoContent = Content.fromUri("rbxassetid://5608359401")
videoSource.Looping = true
videoSource.Parent = videoScreenPart
-- สร้างสถานที่ที่เสียงของวิดีโอออกมา
local speakerPart = Instance.new("Part")
speakerPart.Anchored = true
speakerPart.Parent = workspace
local audioEmitter = Instance.new("AudioEmitter")
audioEmitter.Parent = speakerPart
-- สร้างและเชื่อมต่อสายไฟเพื่อให้วิดีโอนำเสนอภาพและออกเสียง
local videoWire = Instance.new("Wire")
videoWire.SourceInstance = videoSource
videoWire.TargetInstance = videoDisplay
videoWire.Parent = videoSource
local audioWire = Instance.new("Wire")
audioWire.SourceInstance = videoSource
audioWire.TargetInstance = audioEmitter
audioWire.Parent = videoSource
-- เล่นวิดีโอ
-- หมายเหตุ: การเล่นวิดีโอบนเซิร์ฟเวอร์ไม่รับประกันว่าจะโหลดหรือซิงค์สำหรับทุกคลไบท์ การเล่นบนคลไบท์จะดีกว่า
videoSource:Play()
เครื่องเล่นวิดีโอ (ฝั่งไคลเอนต์)
-- สิ่งนี้ควรอยู่ใน "LocalScript" หรือ "Script" ที่ตั้งค่า RunContext เป็น "Client"
-- โค้ดเดียวกับตัวอย่างก่อนหน้าจนถึงส่วน "เล่นวิดีโอ"
-- เล่นวิดีโอหลังจากที่มันโหลดเสร็จ
videoSource:GetPropertyChangedSignal("IsLoaded"):Connect(function()
if videoSource.IsLoaded then
print("วิดีโอโหลดเสร็จแล้ว กำลังเริ่มเล่นใน 2 วินาที.")
wait(2)
videoSource:Play()
end
end)
-- โหลดวิดีโอเพื่อให้พร้อมเมื่อเราต้องการ
videoSource:LoadAsync()
wait(5)
-- ยกเลิกการโหลดวิดีโอเพื่อประหยัดทรัพยากร
videoSource:Unload()

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
AutoLoadInStudio
ไม่ซ้ำ
ไม่สามารถเขียนสคริปต์
การรักษาความปลอดภัยของสคริปต์ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.AutoLoadInStudio:boolean

AutoPlayInStudio
ไม่ซ้ำ
ไม่สามารถเขียนสคริปต์
การรักษาความปลอดภัยของสคริปต์ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.AutoPlayInStudio:boolean

IsLoaded
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.IsLoaded:boolean

IsPlaying
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.IsPlaying:boolean

Looping
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.Looping:boolean

MaximumResolution
ซ่อนอยู่
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI, InternalTest
VideoPlayer.MaximumResolution:Enum.VideoSampleSize

PlaybackSpeed
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.PlaybackSpeed:number

Resolution
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.Resolution:Vector2

TimeLength
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.TimeLength:number

TimePosition
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.TimePosition:number

VideoContent
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.VideoContent:Content

Volume
อ่านพร้อมๆ กัน
ความสามารถ: Audio, UI
VideoPlayer.Volume:number

วิธีการ
GetConnectedWires
ความสามารถ: Audio, UI
VideoPlayer:GetConnectedWires(pin:string):{Wire}
พารามิเตอร์
pin:string
ส่งค่ากลับ

GetInputPins
ความสามารถ: Audio, UI
VideoPlayer:GetInputPins():{any}
ส่งค่ากลับ

GetOutputPins
ความสามารถ: Audio, UI
VideoPlayer:GetOutputPins():{any}
ส่งค่ากลับ

LoadAsync
ผลตอบแทน
ความสามารถ: Audio, UI
VideoPlayer:LoadAsync():Enum.AssetFetchStatus
ส่งค่ากลับ

Pause
ความสามารถ: Audio, UI
VideoPlayer:Pause():()
ส่งค่ากลับ
()

Play
ความสามารถ: Audio, UI
VideoPlayer:Play():()
ส่งค่ากลับ
()

Unload
ความสามารถ: Audio, UI
VideoPlayer:Unload():()
ส่งค่ากลับ
()

เหตุการณ์
DidEnd
ความสามารถ: Audio, UI
VideoPlayer.DidEnd():RBXScriptSignal

DidLoop
ความสามารถ: Audio, UI
VideoPlayer.DidLoop():RBXScriptSignal

PlayFailed
ความสามารถ: Audio, UI
VideoPlayer.PlayFailed(error:Enum.AssetFetchStatus):RBXScriptSignal
พารามิเตอร์

WiringChanged
ความสามารถ: Audio, UI
VideoPlayer.WiringChanged(
connected:boolean, pin:string, wire:Wire, instance:Instance
พารามิเตอร์
connected:boolean
pin:string
wire:Wire
instance:Instance

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ