Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
patrickbulman's avatar
patrickbulman
Honored Guest
11 years ago

GearVR: Setting system volume

Hi there,

I'm using the recommended version of Unity (5.2.2p2) and the latest utilites (0.1.3) targeting GearVR and I'm trying to adjust the system volume by setting the value of OVRPlugin.systemVolume but I get the following error:

F/libc (28289): E:\tw\abb88c8cee4b9679\Software\OculusSDK\Integrations\Unity\Releases\0.1.3.0\OVRPlugin\Src\OVR_Plugin.cpp:351: ovrpBool ovrp_SetFloat(ovrpKey, float): assertion "false" failed

I would like my own volume bar to adjust the system volume of the phone.

Thanks in advance!

9 Replies

Replies have been turned off for this discussion
  • OVRPlugin is an internal API that we don't support people using. As such, it exposes some functions that don't work, such as the setter for systemVolume. Please use OVRManager.volumeLevel to get the current value. To implement your slider, you could set AudioListener.volume. If you're ok with users using the standard volume up/down buttons, you could follow our example in OVRVolumeControl.cs. It just reads the current level and shows a bar when it changes.
  • Thanks for the reply Dave,

    I understand, also worth noting the initial value of OVRPlugin.system volume is defaulted to -0.66, and only becomes accurate after the user presses the volume buttons.
  • You mean -0.066? This is expected. Please use OVRManager.volumeLevel, which will ensure the system is initialized before querying the volume level.
  • The value of OVRManager.volumeLevel is -0.066 until the user presses a volume button. How am I supposed to get the current system volume before the user presses a volume button?
  • Are you trying systemVolume or volumeLevel? Are they both giving the same odd value?
  • Yes, both OVRPlugin.systemVolume and OVRManager.volumeLevel are not initialized properly until they receive input from the user.
  • Anonymous's avatar
    Anonymous
    Was this issue ever solved? I think I am running into something similar (neither are returning a 'proper' value until the buttons are pressed)
  • Please don't make calls directly to OVRPlugin. It's unsupported and "internal" for a reason. OVRManager.volumeLevel is the correct API to use. Unfortunately, it currently still reports -.066 until the first volume change. It is also read-only. If you want to programmatically change the system volume, see http://docs.unity3d.com/Manual/PluginsForAndroid.html and http://sudarmuthu.com/blog/adjusting-the-volume-in-android-through-code.
  • Anonymous's avatar
    Anonymous
    Yep - even with the OVRManager that's what I was getting. I'm not looking to change the volume, just display what it is currently set at. Thanks for the links, I'll look into the writing of a plug-in (which does seem a like overkill for this!).