x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Gear VR] How to do the required volume UI?

It does not appear to be possible to do the required volume UI in UE4 binary using blueprints.

It is required for any submission to Oculus store. See:

https://developer.oculus.com/documentation/mobilesdk/latest/concepts/mobile-umenu-reserved/

&

http://forum.unity3d.com/threads/unity-5-1-for-samsumg-gear-vr-problem-volume-bar-not-showing-for-the-volume-adjustment.338245/

There appears to be something in the Oculus SDK documentation about it such as: https://developer.oculus.com/doc/0.1.0.0-unity/class_o_v_r_volume_control.html#af7b0909826fd67cafef235123860dcc7

I tried creating my own volume UI 3d widget using the assets from the GearVR Mobile SDK however I can't figure out how to get the current volume. Without knowing the current volume you do not know what value to show in the UI.

Can we get these exposed to the blueprints? Otherwise UE4 is still not supporting the entire GearVR distribution process

EDIT: in 4.13 the volume UI is working out of the box and you don't need to do anything at all! ;)

Product Version: UE 4.9
Tags:
more ▼

asked Sep 15 '15 at 06:18 PM in VR

avatar image

aussieburger
1.5k 43 176 75

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

FYI: in 4.13 the volume UI is working out of the box and you don't need to do anything at all! ;)

more ▼

answered Sep 08 '16 at 02:16 PM

avatar image

aussieburger
1.5k 43 176 75

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

If all you need is to get the current volume, you can add a "GetCurrentVolume" Blueprint node by adding the following and rebuilding the editor and Android .so:

In GameActivity.java:

 public int AndroidThunkJava_GetCurrentVolume()
 {    
     AudioManager audioManager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
     return audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
 }

In AndroidJNI.h to FJavaWrapper:

 static jmethodID AndroidThunkJava_GetCurrentVolume;

 static int32 CallIntMethod(JNIEnv* Env, jobject Object, jmethodID Method, ...);

In AndroidJNI.cpp to FJavaWrapper::FindClassesAndMethods:

 AndroidThunkJava_GetCurrentVolume = FindMethod(Env, GameActivityClassID, "AndroidThunkJava_GetCurrentVolume", "()I", bIsOptional);

Add to //Declare all the static members of the class defs:

 jmethodID FJavaWrapper::AndroidThunkJava_GetCurrentVolume;

Add these functions:

 int32 FJavaWrapper::CallIntMethod(JNIEnv* Env, jobject Object, jmethodID Method, ...)
 {
     if (Method == NULL || Object == NULL)
     {
         return false;
     }
 
     va_list Args;
     va_start(Args, Method);
     jint Return = Env->CallIntMethodV(Object, Method, Args);
     va_end(Args);
 
     return (int32)Return;
 }

 int32 AndroidThunkCpp_GetCurrentVolume()
 {
     int32 Result = 0;
     if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
     {
     Result = FJavaWrapper::CallIntMethod(Env, FJavaWrapper::GameActivityThis, FJavaWrapper::AndroidThunkJava_GetCurrentVolume);
     }
     return Result;
 }

Add to KismetSystemLibrary.h:

 /**
 * Returns the current volume (Android only)
 */
 UFUNCTION(BlueprintPure, Category = "Utilities|Platform")
 static int32 GetCurrentVolume();

Add to KismetSystemLibrary.cpp:

 int UKismetSystemLibrary::GetCurrentVolume()
 {
 #if PLATFORM_ANDROID
     extern int32 AndroidThunkCpp_GetCurrentVolume();
 
     return AndroidThunkCpp_GetCurrentVolume();
 #else
     return 0;
 #endif
 }
more ▼

answered Sep 15 '15 at 10:04 PM

avatar image

Chris Babcock STAFF
1k 11 110 35

avatar image aussieburger Sep 16 '15 at 07:12 AM

Hi Chris thanks for the answer,

I'm not 100% sure if that is all that is required but I'll give this a try in the next few days and post again if not!

Would be great to have this as a standard engine feature as well ;)

Cheers, aussieburger

avatar image so2gamemake May 31 '16 at 08:50 AM

Did this source code do the trick? Did you get your app published in the Oculus Store yet?

avatar image aussieburger May 31 '16 at 11:08 AM

Yes it worked and yes I got my game onto the gearvr store :)

We Come In Peace... https://www2.oculus.com/experiences/gear-vr/916630401745678/

Please note that some of the code Chris posted above did make it into the engine from 4.10 on. My guess is the stuff required for a code project made it in, however the stuff required to expose the 'get current volume' node to blueprints is still not in the engine as of 4.11 :( So yeah in case you have troubles compiling check that that part is not already there ;)

avatar image TrujaSanguinaria Jun 16 '16 at 11:56 PM

I've followed all the steps and compiled in Visual Studio but "GetCurrentVolume" node still refuses to appear. Does it have to be compiled somewhere else or I'm missing something obvious?

Thank you!

avatar image motorsep Jun 17 '16 at 12:14 AM

You don't have to be concerned with this any longer as Low Entry implemented this in their plugin: https://www.unrealengine.com/marketplace/low-entry-extended-standard-library

Plus battery charge and temperature.

avatar image TrujaSanguinaria Jun 17 '16 at 10:33 AM

Thank you motorsep! You are being of a great help!

It would be much to ask how the 'Get Volume' node (from LE plugin) works? Cause I've tested it getting the volume and printing strings every time a volume button in gear is pressed, but the string does not seem to vary regardless of the phone's volume. Have I to use this node to get the phone's volume?

Thank you again!

avatar image motorsep Jun 17 '16 at 02:07 PM

I haven't used it yet, but feel free to report bugs to the developer and ask for help/fixes here: https://forums.unrealengine.com/showthread.php?111375-Low-Entry-Plugins

avatar image Superlumen Jul 12 '16 at 04:45 PM

Hi TrujaSanguinaria, did you do the required volume UI in UE4?. I have downloaded the LE Extended plugin to my UE4.11.2 but I'm in the same situation... I don't understand hoy the 'Get Volume' node is working :/ Any help?

avatar image aussieburger Sep 08 '16 at 02:14 PM

FYI: in 4.13 the volume UI is working out of the box and you don't need to do anything at all! ;)

avatar image motorsep Apr 06 '16 at 01:25 PM

Is this coming into 4.12 by chance ?

avatar image motorsep Apr 25 '16 at 01:37 PM

Still wondering whether it's coming into 4.11.x or 4.12

avatar image aussieburger Sep 08 '16 at 02:15 PM

FYI: in 4.13 the volume UI is working out of the box and you don't need to do anything at all! ;)

avatar image SuperlativeGames Sep 08 '16 at 09:16 AM

@Chris Babcock, I followed your instructions and tried to package an APK for Android platforms but I got this error(undefined reference to 'AndroidThunkCpp_GetCurrentVolume()'):
alt text

Somehow my custom UE4 engine was built without any error. Could this be possible?

kismeterror.png (119.6 kB)
avatar image aussieburger Sep 08 '16 at 02:16 PM

FYI: in 4.13 the volume UI is working out of the box and you don't need to do anything at all! ;)

If you really have to use an older version are you sure you compiled the engine for Android development and android shipping and not just windows client.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This should provide missing functionality, plus battery charge and temperature: https://www.unrealengine.com/marketplace/low-entry-extended-standard-library

more ▼

answered Jun 17 '16 at 12:15 AM

avatar image

motorsep
378 39 48 66

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question