Any suggestions? I have tried both OGG and WAV files. I know the asset is being located, because when when the asset can’t be located the error is different.
How can I post my xml in this thread? The java brackets clear out my xml. Here is the error:
Feb 11, 2013 1:14:08 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.RuntimeException: java.lang.NullPointerException
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:576)
at de.lessvoid.nifty.Nifty.fromXml(Nifty.java:479)
at menu.ScreenControllerStart.initialize(ScreenControllerStart.java:57)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:225)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:255)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:238)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.jme3.niftygui.SoundHandleJme.(SoundHandleJme.java:49)
at com.jme3.niftygui.SoundDeviceJme.loadSound(SoundDeviceJme.java:58)
at de.lessvoid.nifty.sound.SoundSystem.addSound(SoundSystem.java:45)
at de.lessvoid.nifty.loaderv2.types.RegisterSoundType.materialize(RegisterSoundType.java:12)
at de.lessvoid.nifty.loaderv2.types.NiftyType.create(NiftyType.java:109)
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:569)
Here’s a little more info. I work primarily in eclipse. Just for giggles, I transferred all my code into the jmeSDK to see if the result is different. It’s not. So what am I doing wrong?
INFO: registerEffect [0]
java.lang.NullPointerException
at com.jme3.niftygui.SoundHandleJme.(SoundHandleJme.java:50)
at com.jme3.niftygui.SoundDeviceJme.loadSound(SoundDeviceJme.java:59)
at de.lessvoid.nifty.sound.SoundSystem.addSound(SoundSystem.java:45)
at de.lessvoid.nifty.loaderv2.types.RegisterSoundType.materialize(RegisterSoundType.java:12)
at de.lessvoid.nifty.loaderv2.types.NiftyType.create(NiftyType.java:109)
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:528)
at de.lessvoid.nifty.Nifty.fromXml(Nifty.java:438)
at menu.ScreenControllerStart.initialize(ScreenControllerStart.java:57)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:219)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:249)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:238)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:722)
Unfortunately I don’t play sounds from nifty so I can’t really help. From what I do remember your xml syntax in the onStartScreen looks wrong, you should check it against the Nifty manual, as said it’s not an area I really know very well tho so I could be way off.
The error occurs with registerSound id=“music” filename=“menu/Assets/Sounds/spacetheme1.ogg” /
This has the smell of a wrong path / bad file name.
My guts tell me it should be “Sounds/spacetheme1.ogg”
I used to use sound with Nifty and I can’t say I’ve had any error except my own. So I very highly suspect either your path or file name (capitalization?) is wrong.
Nope the path is correct. If I use the wrong path, instead of a null pointer exception, I get “AssetNotFoundException”
Feb 11, 2013 5:43:12 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.RuntimeException: com.jme3.asset.AssetNotFoundException: Sounds/spacetheme1.ogg (Buffer)
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:576)
at de.lessvoid.nifty.Nifty.fromXml(Nifty.java:479)
at menu.ScreenControllerStart.initialize(ScreenControllerStart.java:57)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:225)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:255)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:238)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Unknown Source)
Caused by: com.jme3.asset.AssetNotFoundException: Sounds/spacetheme1.ogg (Buffer)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:277)
at com.jme3.audio.AudioNode.(AudioNode.java:140)
at com.jme3.audio.AudioNode.(AudioNode.java:152)
at com.jme3.niftygui.SoundDeviceJme.loadSound(SoundDeviceJme.java:56)
at de.lessvoid.nifty.sound.SoundSystem.addSound(SoundSystem.java:45)
at de.lessvoid.nifty.loaderv2.types.RegisterSoundType.materialize(RegisterSoundType.java:12)
at de.lessvoid.nifty.loaderv2.types.NiftyType.create(NiftyType.java:109)
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:569)
… 9 more
I have found I can make this work, if I point to assets in the nifty-examples.jar file. But if I point to my own assets, I get null pointer. hmmmm…
Tell me why the XML in the picture above shows the “registerSound” with a path of “sound/filename.ogg” (which works) while that other one is “menu/Assets/Sounds/spacetheme1.ogg” (doesn’t work)?
Tell me why the XML in the picture above shows the “registerSound” with a path of “sound/filename.ogg” (which works) while that other one is “menu/Assets/Sounds/spacetheme1.ogg” (doesn’t work)?
“sound/filename.ogg” is the path to assets located in the library file nifty-examples.jar
“menu/Assets/Sounds/spacetheme1.ogg” is the path to assets in my project.
By default the assets path for a project is defined like so: (jme installed dir)~assets~Sounds~etc But you never use the full path, only the path after “assets”.
Could that be the problem? Capitalization is important too! If that’s not the problem then I give up. Sounds, like the above, have worked fine here for the longest time.
I fixed it. My screencontroller was poorly written. Instead of calling my nifty display from simpleInitApp, I was calling nifty from within an AbstractAppState (which was also my screencontroller).