I am getting a null pointer exception when trying to use the audio node
Exception in thread "main" java.lang.NullPointerException at com.jme3.audio.AudioNode.<init>(AudioNode.java:163) at com.jme3.audio.AudioNode.<init>(AudioNode.java:144) at com.scriptblocks.walls.Walls.initAudio(Walls.java:526) at com.scriptblocks.walls.Walls.<init>(Walls.java:522) at com.scriptblocks.walls.Walls.getInstance(Walls.java:107) at com.scriptblocks.walls.Main.main(Main.java:9)
Any Idea what I am missing?
I though maybe it was missing this " compile “org.jmonkeyengine:jme3-jogl:$jmeVersion”" but adding that did not help.
Also the asset.jar that the gradle build creates contains the audio files.
` //------------------Audio-----------------
AudioNode cantMoveBlockAudioNode = initAudio("Sounds/CantMoveBlock.wav");
AudioNode moveBlockAudioNode = initAudio("Sounds/MoveBlock.wav");
private AudioNode initAudio(String soundDirAndName) {
AudioNode audioNode = new AudioNode(assetManager, soundDirAndName, AudioData.DataType.Buffer);
audioNode.setPositional(false);
audioNode.setLooping(false);
audioNode.setVolume(2);
rootNode.attachChild(audioNode);
return audioNode;
}`
Gradle:
`apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'
mainClassName = 'com.scriptblocks.walls.Main'
repositories {
jcenter()
}
ext.jmeVersion = "[3.1,)"
project(":assets") {
apply plugin: "java"
buildDir = rootProject.file("build/assets")
sourceSets {
main {
resources {
srcDir '.'
}
}
}
}
dependencies {
compile "org.jmonkeyengine:jme3-core:$jmeVersion"
compile "org.jmonkeyengine:jme3-desktop:$jmeVersion"
compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion"
compile "org.jmonkeyengine:jme3-jogl:$jmeVersion"
compile "com.simsilica:lemur:1.8.1"
runtime "org.slf4j:slf4j-simple:1.6.1"
runtime "org.codehaus.groovy:groovy-all:2.4.6"
compile "org.jmonkeyengine:jme3-blender:$jmeVersion"
runtime project(':assets')
}
task wrapper(type: Wrapper) {
}
task createDirs << {
def pkg = 'com/scriptblocks/walls'
def dirs = [
file("./src/main/java/$pkg"),
file("./src/main/resources"),
file("./assets/Interface"),
file("./assets/MatDefs"),
file("./assets/Materials"),
file("./assets/Models"),
file("./assets/Scenes"),
file("./assets/Shaders"),
file("./assets/Sounds"),
file("./assets/Textures"),
]
dirs.each {
if (!it.exists()) {
println "Creating " + it
it.mkdirs()
}
if (it.listFiles().length == 0) {
def stub = new File(it, 'removeme.txt')
println "Creating stub file to allow git checkin, file:$stub"
stub.text = "Remove me when there are files here."
}
}
}
`