オーディオを再生する
基本的な再生
インポートされたサウンドウェーブを再生するには、通常のサウンドと同様の関数を使用します。例えば、Sound CueなどのオーディオコンポーネントからPlaySound2D
またはPlay
関数を使用します。
再生の制御
再生時間の巻き戻し
サウンドウェーブの再生時間を巻き戻すには、RewindPlaybackTime
関数を使用します。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
// Rewind playback time of the sound wave for 12.5 seconds
ImportedSoundWave->RewindPlaybackTime(12.5f);
注記
UEバージョン4.27まででは、0より大きい特定の時間から再生を開始したい場合、事前にRewindPlaybackTime
関数を使用する必要があるかもしれません。そうしないと、プロシージャルウェーブの内部エンジン処理の問題により、サウンドが正しく再生されない可能性があります。この問題はバージョン5.0以降のエンジンで修正されています。
再生情報の取得
サウンドウェーブの現在の再生時間を取得するには、GetPlaybackTime
またはGetPlaybackPercentage
関数を使用します。また、GetDuration
関数を使用してサウンドウェーブの長さを取得することもできます。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
// Get the current playback time of the sound wave
float PlaybackTime = ImportedSoundWave->GetPlaybackTime();
// Get the current playback percentage of the sound wave
float PlaybackPercentage = ImportedSoundWave->GetPlaybackPercentage();
// Get the duration of the sound wave
float Duration = ImportedSoundWave->GetDuration();