오디오 재생
기본 재생
가져온 사운드 웨이브를 재생하려면 일반 사운드 웨이브와 동일한 함수를 사용하세요. 예를 들어, PlaySound2D 함수나 Sound Cue와 같은 오디오 컴포넌트의 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();
재생 상태 확인
현재 재생 중인지 확인
사운드 웨이브가 현재 재생 중인지 확인하려면 IsPlaying 함수를 사용할 수 있습니다.
- Blueprint
- C++

// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
// Check if the sound wave is currently playing
bool bIsPlaying = ImportedSoundWave->IsPlaying();
재생이 완료되었는지 확인
사운드 웨이브 재생이 완료되었는지 확인하려면 IsPlaybackFinished 함수를 사용할 수 있습니다.
- Blueprint
- C++

// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
// Check if the sound wave has finished playback
bool bIsFinished = ImportedSoundWave->IsPlaybackFinished();
재생 중지
StopPlayback 함수를 사용하여 사운드 웨이브 재생을 중지할 수 있습니다.
- Blueprint
- C++

// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
// Stop the playback of the sound wave
ImportedSoundWave->StopPlayback();
일반적으로 외부 수단(예: 오디오 컴포넌트에서 Stop 호출)을 사용하여 사운드 웨이브 재생을 중지하는 것이 권장되며, 외부 수단을 사용할 수 없는 경우에 이 함수를 사용하세요. 또한, 이 함수는 MetaSounds에서의 재생에는 작동하지 않습니다.
이벤트 처리
재생 완료 추적
오디오 재생이 끝나는 시점을 추적하려면 OnAudioPlaybackFinished 델리게이트에 바인딩하세요.
- Blueprint
- C++

UCLASS()
class AMyAudioPlayer : public AActor
{
GENERATED_BODY()
public:
UFUNCTION()
void OnAudioFinished()
{
// Handle the end of audio playback
}
void BindAudioDelegate(UImportedSoundWave* ImportedSoundWave)
{
// Bind to the OnAudioPlaybackFinished delegate
ImportedSoundWave->OnAudioPlaybackFinished.AddDynamic(this, &AMyAudioPlayer::OnAudioFinished);
}
};
메모리 관리
메모리 해제
ReleaseMemory 함수를 사용하여 오디오 데이터를 수동으로 지울 수 있습니다.
- Blueprint
- C++

// Release memory of the sound wave
ImportedSoundWave->ReleaseMemory();
메모리 수동 해제는 특정 메모리 관리 요구사항이 있거나 가비지 컬렉터를 비활성화한 경우가 아니라면 권장되지 않습니다.