Closed yixuanqi closed 1 year ago
thanks for your reply, but what could i do via cpp? in the "importing Audio" i find a way to play sound, when i use the same way to get duration it doesn't work. here is my code
RuntimeAudioImporter->OnResultNative.AddWeakLambda(this, [this](URuntimeAudioImporterLibrary* Importer, UImportedSoundWave* ImportedSoundWave, ERuntimeImportStatus Status) { if (Status == ERuntimeImportStatus::SuccessfulImport) { UE_LOG(LogTemp, Warning, TEXT("Successfully imported audio with sound wave %s"), *ImportedSoundWave->GetName()); //UGameplayStatics::PlaySound2D(GetWorld(), ImportedSoundWave); pAudioDuration->SetText(FText::FromString(FString::SanitizeFloat(ImportedSoundWave->GetDuration()) + FString("s"))); } else { UE_LOG(LogTemp, Error, TEXT("Failed to import audio")); } RuntimeAudioImporter = nullptr; });
it seems i can just use AddWeakLambda once to get ImportedSoundWave to play sound or get wave property.
Please refer to the documentation for more information on how to import audio data. It includes a C++ example as well: https://github.com/gtreshchev/RuntimeAudioImporter/wiki/1.-Importing-Audio
To obtain the duration of the sound wave, use the GetDuration function. You can find more information in the documentation.