Video Player
*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.
Resumen
Propiedades
Métodos
GetConnectedWires(pin: string):{Wire} |
GetInputPins():{string} |
GetOutputPins():{string} |
Pause():() |
Play():() |
Unload():() |
Eventos
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
Muestras de código
Reproductor de Video (Lado del Servidor)
-- Esto debe estar en un "Script" con RunContext configurado a "Legacy" o "Server"
-- Crea lo que se muestra en el video
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
-- Crea de dónde proviene un activo de video
local videoSource = Instance.new("VideoPlayer")
videoSource.VideoContent = Content.fromUri("rbxassetid://5608359401")
videoSource.Looping = true
videoSource.Parent = videoScreenPart
-- Crea de dónde emite el audio del video
local speakerPart = Instance.new("Part")
speakerPart.Anchored = true
speakerPart.Parent = workspace
local audioEmitter = Instance.new("AudioEmitter")
audioEmitter.Parent = speakerPart
-- Crea y conecta cables para que el video se renderice visualmente y emita audio
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
-- Reproduce el video
-- Nota: Reproducir un video en el servidor no garantiza que esté cargado o sincronizado para todos los clientes, se prefiere reproducir en el cliente
videoSource:Play()Reproductor de Video (Lado del Cliente)
local videoSource = Instance.new("VideoPlayer")
videoSource.VideoContent = Content.fromUri("rbxassetid://5608359401")
videoSource.Parent = script.Parent
-- Reproduce el video después de que se haya cargado
videoSource:GetPropertyChangedSignal("IsLoaded"):Connect(function()
if videoSource.IsLoaded then
print("El video se ha cargado, comenzando la reproducción en 2 segundos.")
task.wait(2)
videoSource:Play()
end
end)
-- Carga el video para tenerlo listo cuando lo necesitemos
videoSource:LoadAsync()
task.wait(5)
-- Descarga el video para ahorrar recursos
videoSource:Unload()Referencia API
Propiedades
Métodos
Pause
Video Player: Pause():()
Devuelve
()
Play
Video Player: Play():()
Devuelve
()
Unload
Video Player: Unload():()
Devuelve
()
Eventos
Play Failed
Parámetros