I have a method called setSound() which is setting up a queue and adding a track to it and then playing it. I call the method in simpleInitGame(). However no sound plays and the console in eclipse says:
Mar 13, 2012 10:15:55 PM com.jmex.audio.openal.OpenALSystem setupSourcePool
INFO: max source channels: 32
Mar 13, 2012 10:15:55 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: src/com/preston/sounds/background.ogg
Mar 13, 2012 10:15:55 PM com.jmex.audio.openal.OpenALSystem createAudioTrack
WARNING: Could not locate audio file: src/com/preston/sounds/background.ogg
Here is the method:
protected void setSound()
{
audio = AudioSystem.getSystem();
sound1 = audio.createAudioTrack("src/com/preston/sounds/background.ogg", false);
queue = AudioSystem.getSystem().getMusicQueue();
queue.setCrossfadeinTime(0);
queue.setRepeatType(RepeatType.ONE);
queue.addTrack(sound1);
queue.play();
}
I don’t think it’s the directory as my textures are in the same directory (except instead of preston/sounds its preston/textures).
this is most probably a problem with your relative path. The default directory of the ResourceLocatorTool in jMonkeyEngine is not the root of your project. Try to open it with an absolute path and see if it works.
Also, the location of your file is not a wise choice. The src folder is intended for java source files, not resources. You should put them in assets/Sounds. See jME best practices