Android - Assets Manager cannot find audio files

So here is the plan:
first, Ill try fixing the NativeVorbisLoader and remove that restriction
second, if that wont work I’ll delegate the sound commands to the application

2 Likes

I think that option might involve natives inside TremorAndroid.zipwhich jme uses to play audio…

Anyway this is the part that involves loading ogg files with buffer data, before playing source is executed, :

In case for more info

GIT blame was a little illuminating. Found this commit:

Probably the native code cannot unpack assets from jars, etc. and so it’s limited to real android resources.

…or something to that effect.

Edit: note that it should be possible to create DesktopAssetManager with whatever config you want and so maybe override the default asset loading… but then you may lose ogg support on Android, too.

2 Likes

But what makes sound files so special that they are the only ones which cannot be loaded from the storage? all other resources are loading just fine

1 Like

Because ogg files are loaded by a JNI native library and other resources are not?

2 Likes

Ill try using WAVs instead. I can live with that limitation. Yesterday I’ve got a crash while trying to play WAV file. Ill check that

2 Likes

It should work because it uses WAVLocator directly, VorbisLoader is only for .ogg files

2 Likes

With WAV files I don’t get any exceptions either when trying to load from storage or from assets folder but no sound is actually played. I stepped with the debugger on the loading & playing code and everything looks good. again - no sound is played.
My guess is that I need to compile a specific type of WAV file for Android. What do you think? is there such a limitation?

2 Likes

What JME version you are using?

1 Like

Now I tried putting OGG file inside the assets folder and I’m getting this exception while trying to use it:

2021-05-23 11:53:57.245 19974-20023/com.abware.scenemax3dgamehub E/com.jme3.app.AppTask: SEVERE Exception
    java.lang.IllegalArgumentException: capacity < 0: -524
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:237)
        at com.jme3.util.AndroidBufferAllocator.allocate(AndroidBufferAllocator.java:111)
        at com.jme3.util.BufferUtils.createByteBuffer(BufferUtils.java:989)
        at com.jme3.audio.plugins.NativeVorbisLoader.loadBuffer(NativeVorbisLoader.java:72)
        at com.jme3.audio.plugins.NativeVorbisLoader.load(NativeVorbisLoader.java:130)
        at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:260)
        at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:374)
        at com.jme3.audio.AudioNode.<init>(AudioNode.java:164)
        at com.jme3.audio.AudioNode.<init>(AudioNode.java:144)
        at com.scenemaxeng.projector.SceneMaxApp$3.run(SceneMaxApp.java:884)
        at com.jme3.app.LegacyApplication$RunnableWrapper.call(LegacyApplication.java:786)
        at com.jme3.app.AppTask.invoke(AppTask.java:142)
        at com.jme3.app.LegacyApplication.runQueuedTasks(LegacyApplication.java:701)
        at com.jme3.app.LegacyApplication.update(LegacyApplication.java:715)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:246)
        at com.jme3.app.AndroidHarnessFragment.update(AndroidHarnessFragment.java:577)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:348)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)

3.3.2

implementation "org.jmonkeyengine:jme3-core:3.3.2-stable"
implementation "org.jmonkeyengine:jme3-effects:3.3.2-stable"
implementation "org.jmonkeyengine:jme3-android-native:3.3.2-stable"
1 Like

I think that is the reason. Android sound is broken in 3.3. It is fixed in 3.4.0-alpha4 and above.

2 Likes

Thanks for the info. So I will leave all the audio stuff for now and focus on other things. Do you know what is the ETA for 3.4?

1 Like

Idk. But the beta version is avialble if you wish to try.

2 Likes

Can I refer to the BETA from gradle?

1 Like

Yes.

2 Likes

I’ll try. Thank you. can you specify or point me to a documentation what do I need to put in the gradle?
something like 3.4.0-betta for every component

2 Likes

3.4.0-beta4

Edit:
You can find the list of available tags here

3 Likes

Thank you! with version 3.4-beta4 I can play both OGG & WAV files from my assets folder. I still didn’t succeed playing wav files from an internal storage folder. I hope will find a way to do that otherwise its bad news for my project…

3 Likes

Yes, that is what I would suggest doing. Interested to hear about the result.

Edit:
By the way, there is also a similar topic. Hope it helps…

1 Like