在UE5 里面尝试获取 当前播放的event 的position ,但是一直获取失败,返回的是AK_PlayingIDNotFound,Wwise 取消Auto Defind SoundBank之后,返回的是AK_NotInitialized
int32 UAkGameplayStatics::GetSourcePlayPosition(int32 PlayingID)
{
AkTimeMs Position = 0;
auto Result = AK::SoundEngine::GetSourcePlayPosition((AkPlayingID)PlayingID, &Position);
if (Result != AKRESULT::AK_Success)
{
UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::GetSourcePlayPosition: Failed"));
return Result;
}
else return (int32)Position;
}
这个是我的函数,并且我已经明确传递EnableGetSourcePlayPosition 给事件,以及初始化引擎,初始化返回success
void UWwiseSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
AkMemSettings MemSettings;
AK::MemoryMgr::GetDefaultSettings(MemSettings);
AK::MemoryMgr::Init(&MemSettings);
AkStreamMgrSettings StreamMgrSettings;
AK::StreamMgr::GetDefaultSettings(StreamMgrSettings);
AK::StreamMgr::Create(StreamMgrSettings);
//Init Sound Engine
AkInitSettings InitSettings;
AkPlatformInitSettings PlatformInitSettings;
// 配置初始化设置
AK::SoundEngine::GetDefaultInitSettings(InitSettings);
AK::SoundEngine::GetDefaultPlatformInitSettings(PlatformInitSettings);
AKRESULT Result = AK::SoundEngine::Init(&InitSettings, &PlatformInitSettings);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Init Sound Engine : %d"), Result));
}
查了很多资料,翻了很文章,都没有说明这里的下一步是什么,怎么修复这里的Bug,所以怎么样才可以通过 Post Event 的Playing 获取当前播放的SFX的 position