Video Player
요약
속성
메서드
GetConnectedWires(pin: string):{Wire} |
GetInputPins():{string} |
GetOutputPins():{string} |
Pause():() |
Play():() |
Unload():() |
이벤트
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
상속된 멤버
코드 샘플
비디오 플레이어 (서버 측)
-- 이 코드는 "Legacy" 또는 "Server"로 설정된 RunContext의 "Script"에 있어야 합니다.
-- 비디오가 표시될 화면을 생성합니다.
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.fromScale(1, 1)
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()비디오 플레이어 (클라이언트 측)
local videoSource = Instance.new("VideoPlayer")
videoSource.VideoContent = Content.fromUri("rbxassetid://5608359401")
videoSource.Parent = script.Parent
-- 비디오가 로드된 후 재생
videoSource:GetPropertyChangedSignal("IsLoaded"):Connect(function()
if videoSource.IsLoaded then
print("비디오가 로드되었습니다. 2초 후 재생을 시작합니다.")
task.wait(2)
videoSource:Play()
end
end)
-- 비디오를 로드하여 필요할 때 준비
videoSource:LoadAsync()
task.wait(5)
-- 자원을 절약하기 위해 비디오 언로드
videoSource:Unload()API 참조
속성
메서드
Pause
Video Player: Pause():()
반환
()
Play
Video Player: Play():()
반환
()
Unload
Video Player: Unload():()
반환
()
이벤트
Play Failed