[SOLVED] Audio is not playing?

Hey everyone, I unpacked the HelloAudio program and ran it but there is simply no audio? The audio files are in the correct locations

Here’s the code (basically a slightly modified version of HelloAudio):

package jme3test.helloworld;

import com.jme3.app.SimpleApplication;
import com.jme3.audio.AudioNode;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

/** Sample 11 - playing 3D audio. */
public class NewClass extends SimpleApplication {

private AudioNode audio_gun;
private AudioNode audio_nature;
private Geometry player;

public static void main(String[] args) {
NewClass app = new NewClass();

public void simpleInitApp() {

/** just a blue box floating in space */
Box box1 = new Box(1, 1, 1);
player = new Geometry("Player", box1);
Material mat1 = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.Blue);

/** custom init methods, see below */


/** We create two audio nodes. /
private void initAudio() {
gun shot sound is to be triggered by a mouse click. */
audio_gun = new AudioNode(assetManager, “Sound/Effects/Gun.ogg”, false);

/* nature sound - keeps playing in a loop. */
audio_nature = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", true);
audio_nature.setLooping(true);  // activate continuous playing
audio_nature.play(); // play continuously!


/** Declaring “Shoot” action, mapping it to a trigger (mouse left click). */
private void initKeys() {
inputManager.addMapping(“Shoot”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, “Shoot”);

/** Defining the “Shoot” action: Play a gun sound. */
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals(“Shoot”) && !keyPressed) {
audio_gun.playInstance(); // play each instance once!

/** Move the listener with the a camera - for 3D audio. */
public void simpleUpdate(float tpf) {


are you running linux? if yes which distro

What version of JME are you running, HelloAudio works fine for me on the following build.

INFO: Running on jMonkeyEngine 3.1-5269
 * Branch: master
 * Git Hash: 5da9fa6
 * Build Date: 2015-09-24

I’m running Windows 7 Ultimate

When I start up jmonkeyengine, it says:
Running on jMonkeyEngine 3.0.10

Also when I check for updates, it said my client is the latest version

Comment the code that creates a blue cube at the center. Do you still view the cube?

Yes I can view the cube and rotate the camera around, but there is no sound.

I came across a thread saying that stereo sound doesn’t work so I tried a mono .ogg file but still doesn’t work

You are probably running the game by pressing F6. There was a similar problem with another guy.

Use Shift + F6 when you want to run the class that you are working on. The F6 runs the MAIN class, the Shift + F6 runs the class that is currently opened.

And, when you develop a game, you should only have one main class.

1 Like

Ahhhh yes that got it working. Thanks so much for your help.

1 Like

I’m getting another problem now, when I try to change the path of the audio so it plays my own audio, I get this error:

Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
StringIndexOutOfBoundsException: String index out of range: -1

Also how is JME playing a sound that doesn’t even exist in my hard drive? The default audio files are:
“Sound/Effects/Gun.wav” and “Sounds/Environment/Ocean Waves.ogg”
I cant even find these 2 files in my entire hard drive

Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
StringIndexOutOfBoundsException: String index out of range: -1

Posting the exception is not enough. Post the code that is getting errors.

Also how is JME playing a sound that doesn’t even exist in my hard drive? The default audio files are:
“Sound/Effects/Gun.wav” and “Sounds/Environment/Ocean Waves.ogg”
I cant even find these 2 files in my entire hard drive

The JME-test-data jar already contains some files for you to use. Such as some Material Definitions, it also comes bundled with some sounds, and even some assets.

To reiterate what evilblow says because it’s so common as to be nearly infuriating…

Let’s pretend an exception is a book about tigers and you have a sick tiger. Posting an exception without a stack trace is like giving us just the cover of the book. Useful in that, yes, we can see it’s a book about tigers… but useless in that it left out all of the important bits about tigers.

Of course, we will also need to examine the tiger for final diagnosis.

Apologies if this is a necropost, but I’ve got exactly the same problem as Valachio in that I’m suddenly not getting any sound in my game. I’ve also tried running HelloAudio and linked the source code. The thread gets all the way to AL libraries, but no sound comes out. I’m running Windows 10 and the sound is turned on. The sound was working a few days ago, but for some reason now nothing, but no errors. I’ve tried changing app.settings.setAudioRenderer(LWJGL_OPEN_AL) and others. Is there anything else I can try? Thanks in advance.

What changed on your computer in the last few days?

Nothing major, probably only some Windows updates that seem to come along every so often. However, I’ve tried one of my other projects and the sound works fine on that one, on the same PC. They both use the exact same JME libs.

The only thing I can think of that might point to be a cause is that I added JMECapture to this project. I’ve removed it now though. However, even unmodified HelloAudio doesn’t work.

Just solved it! I’ve no idea how about the technicalities, but I deleted the DLLs that get automatically created in the root of the project. These then got recreated, and it all works fine again. Does JMECapture affect these or something?

1 Like

jME automatically extracts whatever native libs it needs for the system it’s running on when you start your jME application. I’m not 100% positive (would need to check the source), but my guess is that it won’t extract the libs if they are already there - meaning that older versions of libs won’t get upgraded unless you force it to re-extract by doing what you just did. Sounds like since you deleted the old (nonfunctional) libs it extracted a newer version that is working on your machine.

There is a check to see if the ones that are packaged are newer than the ones already there. It’s possible that this check was confused in this case for some reason.

I sometimes have to delete the .dlls jME creates, or else it won’t even boot the game. Specifically bulletjme.dll

Makes sense. I was browsing around the native extraction code the other day (for a different reason) and didn’t notice any bits about handling library versions so I assumed that it didn’t have a mechanism for that.