AudioDeviceOutput 接受音频流以便渲染到物理硬件设备,例如扬声器或耳机。它提供一个单个 输入 端口,可以由 Wires 目标。任何通过 0> Class.AudioDeviceOutput0> 传输的音频流都可以听到。
代码示例
Outputting Audio to Device
local audioPlayer : AudioPlayer = Instance.new("AudioPlayer")
audioPlayer.Parent = workspace
audioPlayer.AssetId = "rbxassetid://9112854440"
local deviceOutput = Instance.new("AudioDeviceOutput")
deviceOutput.Parent = workspace
local wire = Instance.new("Wire")
wire.Parent = workspace
wire.SourceInstance = audioPlayer
wire.TargetInstance = deviceOutput
audioPlayer:Play()