Sound file not found


E/AndroidAudioRenderer(16267): java.io.FileNotFoundException: Sounds/page-flip.wav
E/AndroidAudioRenderer(16267): at android.content.res.AssetManager.openAssetFd(Native Method)
E/AndroidAudioRenderer(16267): at android.content.res.AssetManager.openFd(AssetManager.java:331)
E/AndroidAudioRenderer(16267): at com.jme3.audio.android.AndroidAudioRenderer.playSourceInstance(AndroidAudioRenderer.java:333)
E/AndroidAudioRenderer(16267): at com.jme3.audio.AudioNode.playInstance(AudioNode.java:256)
E/AndroidAudioRenderer(16267): at v3l.client.scene.ReadingScene.flipForward(ReadingScene.java:371)
E/AndroidAudioRenderer(16267): at v3l.client.scene.ReadingScene.onTouch(ReadingScene.java:513)
E/AndroidAudioRenderer(16267): at com.jme3.input.InputManager.onTouchEventQueued(InputManager.java:876)
E/AndroidAudioRenderer(16267): at com.jme3.input.InputManager.processQueue(InputManager.java:807)
E/AndroidAudioRenderer(16267): at com.jme3.input.InputManager.update(InputManager.java:851)
E/AndroidAudioRenderer(16267): at com.jme3.app.Application.update(Application.java:605)
E/AndroidAudioRenderer(16267): at com.jme3.app.SimpleApplication.update(SimpleApplication.java:233)
E/AndroidAudioRenderer(16267): at com.jme3.app.AndroidHarness.update(AndroidHarness.java:430)
E/AndroidAudioRenderer(16267): at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:367)
E/AndroidAudioRenderer(16267): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1431)
E/AndroidAudioRenderer(16267): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1180)
I/com.jme3.scene.Node(16267): INFO Node 9:53:01 PM Child (BitmapFont) attached to this node (null)


Hello Jmonkey, I currently try to play a sound in Android Application that created by Jmonkey. It work fine on PC , however, it show above error when running on android, which I sure that the sound file is already in asset.jar

What happend???

Thanks you in advance

Oop, sorry I just see

http://hub.jmonkeyengine.org/groups/sound/forum/topic/problem-with-ogg-vorbis-music-file-and-android-deployment/

which is the same problem as me except my file is wav file.



The problem still cannot be solved

The path is case sensitive

l quite sure that the path is correct. the sound can be play in pc but not in Android. l still dont know why:-(

The audio files needs to be in the android asset folder in order to be opened by openFd.

You can copy them by hand, but this is ugly because you’ll have them twice.



You can make the asset-build to copy the jme assets in the appropriate folder.

1 Like

Sorry, I don’t understand. There are audio files in asset.jar in Mobile project. However, what do you mean “android asset folder”? do I have to create one on my own ?



Thank you :slight_smile:

Ah. No, there is a bug where audio files cannot be played from a jar file on android.

Wow, thank you. It’s exactly as you said. My problem is already solved :slight_smile:

Hi folks I just spent some time trouble shooting this issue aswell (Initially I tried putting the files in raw, and raw/Sounds

no go

after googling around I found this ‘reference from android dev guide’



Arbitrary files to save in their raw form. To open these resources with a raw InputStream, call Resources.openRawResource() with the resource ID, which is R.raw.filename.



However, if you need access to original file names and file hierarchy, you might consider saving some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a resource ID, so you can read them only using AssetManager.

(where the assets folder is parallel to the /res folder.



In summary:

(raw != assets folder)

You will need to create a new folder parallel to the /res folder called assets, then copy/move your sound files into assets so end up with: assets/Sounds/).





Cheers

2 Likes

Thanks danomano, your answer has shown me the path to the light!!

Now I can play sounds on android. Yeah!



What I did is to copy (by hand) the sound carpet from the typical jMonkey asset folder to a new folder created inside the mobile folder called asset.



Then with this code:



[java]

sonidoAmbiente= new AudioNode(assetManager, "Sounds/loop.ogg", true);

sonidoAmbiente.setVolume(3);

sonidoAmbiente.setLooping(true);

audioRenderer.playSource(sonidoAmbiente);

[/java]



I can play the sound!!!