[SOLVED] Audio cannot be play in AppState

Hi there !

I meet another problem now. I want to play some audio in my AppState,but it didn’t working and show the error below:

Jan 02, 2020 8:20:50 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.2-stable
 * Branch: HEAD
 * Git Hash: 8291d61
 * Build Date: 2019-07-27
Jan 02, 2020 8:20:50 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
Jan 02, 2020 8:20:50 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel Open Source Technology Center
 * Renderer: Mesa DRI Intel(R) Sandybridge Desktop 
 * OpenGL Version: 3.0 Mesa 19.0.8
 * GLSL Version: 1.30
 * Profile: Compatibility
Jan 02, 2020 8:20:50 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
Jan 02, 2020 8:20:50 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Jan 02, 2020 8:20:50 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Jan 02, 2020 8:20:50 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Jan 02, 2020 8:20:50 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
Ogg packet header is 0x52494646 (RIFF), should be 0x4f676753 (OggS)
Jan 02, 2020 8:20:50 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
	at de.jarnbjo.ogg.LogicalOggStreamImpl.getNextOggPacket(LogicalOggStreamImpl.java:88)
	at de.jarnbjo.vorbis.VorbisStream.<init>(VorbisStream.java:79)
	at com.jme3.audio.plugins.OGGLoader.load(OGGLoader.java:276)
	at com.jme3.audio.plugins.OGGLoader.load(OGGLoader.java:309)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:259)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:373)
	at com.jme3.audio.AudioNode.<init>(AudioNode.java:163)
	at com.jme3.audio.AudioNode.<init>(AudioNode.java:144)
	at mygame.SpaceShipAppState.addAudio(SpaceShipAppState.java:100)
	at mygame.SpaceShipAppState.initialize(SpaceShipAppState.java:74)
	at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:236)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
	at java.lang.Thread.run(Thread.java:748)

And it is my coding:

shootSound = new AudioNode(assetManager,"Sounds/Shoot/shot.ogg",DataType.Buffer);

What is the problem of this case , is this my coding type wrong or it was the format of audio cannot support by jMonkeyEngine ?
Thanks for all for your reply ! :smiley:

ogg files are supported as long as you have included the ogg dependency.

compile "org.jmonkeyengine:jme3-jogg:3.3.0-alpha5"

Have you checked that the file will play in another player such as VLC?

Looks to me like the file is not a Vorbis file. You may be able to convert it.

Actually we should fail earlier then instead of having a NullPointerException “somewhere”

1 Like

Yes, the sound can play at VLC.

Thanks for all of you very much, I using FormatFactory to convert it again and jMonkeyEngine can play it well. :upside_down_face:

1 Like

I opened an issue at GitHub:

1 Like