Audio Recorder
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm tắt
Phương Pháp
Clear():() |
GetConnectedWires(pin: string):{Wire} |
GetInputPins():{string} |
GetOutputPins():{string} |
RecordAsync():() |
Stop():() |
Sự Kiện
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
Mẫu mã
Ghi âm âm thanh
local Workspace = game:GetService("Workspace")
local audioRecorder = Instance.new("AudioRecorder")
audioRecorder.Parent = Workspace
local audioPlayer = Instance.new("AudioPlayer")
audioPlayer.Asset = "rbxassetid://5829815715"
audioPlayer.Volume = 0.8
audioPlayer.Parent = Workspace
-- Kết nối AudioPlayer vào AudioRecorder
local wire1 = Instance.new("Wire")
wire1.SourceInstance = audioPlayer
wire1.TargetInstance = audioRecorder
wire1.Parent = audioRecorder
-- Không có cách chính xác để xác định khi nào bộ đệm âm thanh vào để kích hoạt ghi âm đúng cách
-- Ghi âm sẽ có khoảng lặng trống trước so với tài sản gốc
audioPlayer:Play()
audioRecorder:RecordAsync() -- Bắt đầu ghi âm AudioPlayer
print("Đang ghi âm...")
task.wait(5)
audioRecorder:Stop() -- Dừng ghi âm
print("Đã dừng ghi âm!")
audioPlayer:Stop()
audioPlayer.TimePosition = 0
-- Tạo đầu ra để nghe kết quả
local audioOutput = Instance.new("AudioDeviceOutput")
audioOutput.Parent = Workspace
local wire2 = Instance.new("Wire")
wire2.SourceInstance = audioPlayer
wire2.TargetInstance = audioOutput
wire2.Parent = audioOutput
-- Lấy nội dung đã ghi và phát lại trong AudioPlayer
local resultUri = audioRecorder:GetTemporaryContent().Uri
audioPlayer.Asset = resultUri
if not audioPlayer.IsReady then
audioPlayer:GetPropertyChangedSignal("IsReady"):Wait()
end
audioPlayer:Play()Tài Liệu Tham Khảo API
Thuộc Tính
Phương Pháp
Clear
Audio Recorder: Clear():()
Lợi Nhuận
()
Get Unrecordable Instances Async
Record Async
Audio Recorder: Record Async():()
Lợi Nhuận
()
Stop
Audio Recorder: Stop():()
Lợi Nhuận
()
Sự Kiện