Skip to main content
Up and Coming
May 18, 2023

Requesting Audio Focus on Quest 2

Hello everyone, my company has a social app on Quest 2. There is an intermittent and unpredictable bug that happens where 100% of the sound from the app cuts out and the user hears nothing. We cannot find any consistent way to reproduce the problem but it happens somewhat regularly for users in normal conditions. 

Taking a look at some debug values, no audio sources are muted and the audio listener is also not muted. The device volume is up and the audio listener volume is also full. I was trying to determine on what level the device was muted when I found that setting up an android listener to check if we had audio focus CAUSED the problem. This is the command called:

var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
s_mainActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
s_androidAudioManager = s_mainActivity.Call<AndroidJavaObject>("getSystemService", "audio");
int result = s_androidAudioManager.Call<Int32>("requestAudioFocus", listenerToUse, 3, 1);


From everything I can tell reading the Android documentation, this command "requestAudioFocus" is intended to ask for audio focus for your app. In practice, it does the exact opposite on Quest. Any time this command is run, the audio cuts out completely. I am trying to find some way of undoing this loss of audio so that when users lose audio at random I can correct the problem. Currently the only way to regain audio is pressing the power button on the Quest twice. This solution fixes the problem when users encounter the error and also when I run the Android audio focus request. 


Is there a correct way to regain audio focus on Quest when it is lost? Are there reasons why audio focus would be lost? Any help would be appreciated, thank you.

    This topic has been closed for replies.

    4 replies

    New Participant
    May 19, 2023

    Adding that we're hitting this exact same issue in our title.

     

    Max

    New Participant
    October 12, 2023

    Same here! I actually see this happen when toggling the meta dashboard while playing our game. It's not every time but after several attempts, the audio will cut out or in. 

    MetaStoreHelp
    Community Manager
    October 18, 2023

    Hey mattsich! Thank you for bringing this to our attention. We understand that you're having issues with your audio cutting in and out and know how that can affect your gaming experience. No worries; we'll be happy to help. Could you please answer the following:

     

    We look forward to your response!

    If you're the author of a thread, remember to mark a reply as the Accepted Solution to help others find answers!