I need to load a song and play it during the opening screen of my application, even though the file is in the data folder. I still recieve a NullPointerException.
Here's my sound setup code:
- import ddf.minim.*;
- AudioPlayer title_music;
- AudioPlayer jacob_fire;
- AudioPlayer enemy_fire;
- AudioPlayer level1_music;
- AudioPlayer explosion;
- AudioPlayer damage;
- Minim minim;
- void setupSound()
- {
- minim = new Minim(this);
- title_music = minim.loadFile("/sfx/explosion.wav");
- }
- void playTitleMusic()
- {
- if(GAME_STATE == MAIN_MENU)
- {
- title_music.play();
- title_music.loop();
- }
- else
- {
- title_music.pause();
- }
- }
- void stop()
- {
- title_music.close();
- //jacob_fire.close();
- //enemy_fire.close();
- //level1_music.close();
- //explosion.close();
- //damage.close();
- minim.stop();
- super.stop();
- }
Also here is the error:
- ==== JavaSound Minim Error ====
- ==== IOException: Resetting to invalid mark
- Exception in thread "Animation Thread" java.lang.NullPointerException
- at ddf.minim.javasound.JSMinim.getAudioRecordingStream(Unknown Source)
- at ddf.minim.Minim.loadFile(Unknown Source)
- at ddf.minim.Minim.loadFile(Unknown Source)
- at JTVG.setupSound(JTVG.java:270)
- at JTVG.setup(JTVG.java:35)
- at processing.core.PApplet.handleDraw(PApplet.java:2117)
- at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
- at processing.core.PApplet.run(PApplet.java:2020)
- at java.lang.Thread.run(Thread.java:680)