Video Player
概要
プロパティ
イベント
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
コードサンプル
ビデオプレイヤー(サーバー側)
-- これは "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.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