AudioDeviceInput

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

AudioDeviceInput 从物理设备,例如麦克风,产生音频流。它提供了一个单个 输出 端子,可以通过 Wires 连接到其他端子。AudioDeviceInput 有选择哪个 Player 产生串流的属性,以及是否静音的控件。

概要

属性

方法

活动

属性

读取并联

决定是否将提供给 SetUserIdAccessList 的用户 ID 列表视为允许列表或拒绝列表。

如果 AccessTypeEnum.AccessModifierType.Allow , then 只有 供应的用户 ID 是 允许 听到这个 AudioDeviceInput .如果 是 ,那么 只有 供应的用户 ID 被 阻止听到这个 。

由于玩家声音是网络的,此属性应仅从服务器分配,以便正确复制。

Active

Roblox 脚本安全性
读取并联

控制物理设备是否正在录制。此属性仅由 Roblox 核心脚本设置,但可由用户脚本阅读。一般来说,一个 只能生产声音,如果 是真的,而 是错误的。

IsReady

只读
未复制
Roblox 脚本安全性
读取并联

表示这个 AudioDeviceInput 是否准备好产生声音,即所有网络连接已建立。

Muted

读取并联

控制这个 AudioDeviceInput 是否静音。与 Active 不同,该属性是公共可脚本的。

一般来说,一个 AudioDeviceInput 只能被听到,如果 Active 是真的 Muted 是错误的。

代码示例

Push-to-talk

local players = game:GetService("Players")
local userInput = game:GetService("UserInputService")
local audioIn: AudioDeviceInput = players.LocalPlayer:WaitForChild("AudioDeviceInput")
audioIn.Muted = true
local pushToTalkKey = Enum.KeyCode.V
userInput.InputBegan:Connect(function(input: InputObject)
if input.KeyCode == pushToTalkKey then
audioIn.Muted = false
end
end)
userInput.InputEnded:Connect(function(input: InputObject)
if input.KeyCode == pushToTalkKey then
audioIn.Muted = true
end
end)

MutedByLocalUser

未复制
Roblox 脚本安全性
读取并联

Player

读取并联

确定谁的设备产生声音。为了正确复制,这应该仅从服务器分配。本地分配此属性通常不会工作,除非 PlayerPlayers.LocalPlayer

Volume

读取并联

被输出音频串流乘以的音量级别。范围为 0 到 3。

方法

GetConnectedWires

Instances

返回连接到指定端置顶的 Wires 阵列。 AudioDeviceInput 有一个 "输出" 置顶。

参数

pin: string
默认值:""

返回

Instances

GetInputPins


返回

GetOutputPins


返回

GetUserIdAccessList

返回一个列表,包含用户 ID,可以听到或被阻止听到此 AudioDeviceInput ,取决于 AccessType


返回

SetUserIdAccessList

()

设置一列用户 ID,可以听到或被阻止听到这 AudioDeviceInput ,取决于 AccessType

请注意,这个方法从服务器复制到客户端;一般来说,只能从服务器调用才能正确复制。

参数

userIds: Array
默认值:""

返回

()

活动

WiringChanged

Wire 连接或断开后发生的事件,该 Wire 现在或之前已连接到 AudioDeviceInput 上的某个引脚或其他可连接的实例。

参数

connected: boolean

实例是否连接或断开。

pin: string

AudioDeviceInput 上的按钮,用于 Wire 目标。

wire: Wire

之间的 Wire 和其他实例之间的 AudioDeviceInput

instance: Instance

连接到 Wire 通过的另一个实例。