エンジンクラス
AudioRecorder
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
Clear():() |
GetConnectedWires(pin: string):{Wire} |
RecordAsync():() |
Stop():() |
イベント
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
コードサンプル
オーディオレコーダー
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
-- AudioRecorderにAudioPlayerを接続します
local wire1 = Instance.new("Wire")
wire1.SourceInstance = audioPlayer
wire1.TargetInstance = audioRecorder
wire1.Parent = audioRecorder
-- 音声バッファが入るタイミングを正確に判断する方法はありません
-- レコーディングは元のアセットに比べて、先頭に空の沈黙が含まれます
audioPlayer:Play()
audioRecorder:RecordAsync() -- AudioPlayerの録音を開始します
print("録音中...")
task.wait(5)
audioRecorder:Stop() -- 録音を停止します
print("録音を停止しました!")
audioPlayer:Stop()
audioPlayer.TimePosition = 0
-- 結果を聞くための出力を作成します
local audioOutput = Instance.new("AudioDeviceOutput")
audioOutput.Parent = Workspace
local wire2 = Instance.new("Wire")
wire2.SourceInstance = audioPlayer
wire2.TargetInstance = audioOutput
wire2.Parent = audioOutput
-- 録音された内容を取得し、AudioPlayerで再生します
local resultUri = audioRecorder:GetTemporaryContent().Uri
audioPlayer.Asset = resultUri
if not audioPlayer.IsReady then
audioPlayer:GetPropertyChangedSignal("IsReady"):Wait()
end
audioPlayer:Play()APIリファレンス
プロパティ
方法
Clear
AudioRecorder:Clear():()
戻り値
()
RecordAsync
AudioRecorder:RecordAsync():()
戻り値
()
Stop
AudioRecorder:Stop():()
戻り値
()
イベント