Last active
May 25, 2021 00:42
-
-
Save error454/7403e51e89fafaa29cfad716b5b6d815 to your computer and use it in GitHub Desktop.
Vivox UE4 Quest Microphone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "AndroidPermissionFunctionLibrary.h" | |
#include "AndroidPermissionCallbackProxy.h" | |
void SomeFuncWhereYouNeedPermissions() | |
{ | |
#if PLATFORM_ANDROID | |
// If we don't have the permission | |
if (!UAndroidPermissionFunctionLibrary::CheckPermission(TEXT("android.permission.RECORD_AUDIO"))) | |
{ | |
// Build an array of permissions to request | |
TArray<FString> Perms; | |
Perms.Add(TEXT("android.permission.RECORD_AUDIO")); | |
if (UAndroidPermissionCallbackProxy* Callback = UAndroidPermissionFunctionLibrary::AcquirePermissions(Perms)) | |
{ | |
// Bind to the callback so we know when permissions have been granted | |
Callback->OnPermissionsGrantedDelegate.BindLambda([this](const TArray<FString>& Permissions, const TArray<bool>& GrantResults) | |
{ | |
// If you requested more than 1 permission, then you should check the Permissions array to see if | |
// your specific permission got granted. In this case, we only requested a single permission. | |
if (GrantResults.Num() > 0) | |
{ | |
if (GrantResults[0]) | |
{ | |
// We got RECORD_AUDIO permission, now we can use the mic | |
Login(GetFirstGamePlayer()->GetPreferredUniqueNetId()->ToString()); | |
} | |
} | |
}); | |
} | |
} | |
else | |
{ | |
// We already had permissions so continue using the mic | |
UE_LOG(LogTemp, Warning, TEXT("Already had RECORD_AUDIO permissions")); | |
Login(GetFirstGamePlayer()->GetPreferredUniqueNetId()->ToString()); | |
} | |
#else // Not Android | |
Login(GetFirstGamePlayer()->GetPreferredUniqueNetId()->ToString()); | |
#endif | |
} |
It should be located prior to any code that tries to use the microphone.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, this looks great. Have been having problems trying to integrate Vivox and no microphone access on the Quest. Where should this code be located?