java - Jar Sound Loading Error NullPointerException -
i have next class stores sounds i'm gonna use game i'm doing, i'm trying test jar file see if working , find next error command prompt
exception in thread "main" java.lang.nullpointerexception @ com.sun.media.sound.standardmidifilereader.getsequence(unknown source) @ javax.sound.midi.midisystem.getsequence(unknown source) @ com.sun.media.sound.softmidiaudiofilereader.getaudioinputstream(unknown source) @ javax.sound.sampled.audiosystem.getaudioinputstream(unknown source) @ assets.audiostreaming.loadmusicassets(audiostreaming.java:27) @ crossymain.mainmenu.<init>(mainmenu.java:64) @ crossymain.principal.main(principal.java:18)
this class i'm storing audio assets
package assets; import java.io.ioexception; import javax.sound.sampled.*; public class audiostreaming { private static clip mainmenu,bgm,coinp,gameover,trainalert,birdgo; private static audioinputstream in_mainmenu,in_bgm,in_coinp,in_gameover,in_trainalert,in_birdgo; public static void loadmusicassets(){ try{ /*background*/ bgm = audiosystem.getclip(); in_bgm = audiosystem.getaudioinputstream(audiostreaming.class.getresource("/sound/background/neonw.wav")); bgm.open(in_bgm); coinp = audiosystem.getclip(); in_coinp = audiosystem.getaudioinputstream(audiostreaming.class.getresource("/sound/entityfx/coinpickup.wav")); coinp.open(in_coinp); gameover = audiosystem.getclip(); in_gameover = audiosystem.getaudioinputstream(audiostreaming.class.getresource("/sound/entityfx/gameover.wav")); gameover.open(in_gameover); trainalert = audiosystem.getclip(); in_trainalert = audiosystem.getaudioinputstream(audiostreaming.class.getresource("/sound/entityfx/trainwarning.wav")); trainalert.open(in_trainalert); birdgo = audiosystem.getclip(); in_birdgo = audiosystem.getaudioinputstream(audiostreaming.class.getresource("/sound/entityfx/eaglepickup.wav")); birdgo.open(in_birdgo); mainmenu = audiosystem.getclip(); in_mainmenu = audiosystem.getaudioinputstream(audiostreaming.class.getresource("/sound/background/neonvalley.wav")); mainmenu.open(in_mainmenu); }catch(lineunavailableexception | unsupportedaudiofileexception | ioexception e){ e.printstacktrace(); } } public static void playbgm(){ bgm.setframeposition(0); bgm.start(); } public static void stopbgm(){ bgm.stop(); bgm.close(); } public static void playmainmenu(){ mainmenu.setframeposition(0); mainmenu.start(); } public static void stopmainmenu(){ mainmenu.stop(); mainmenu.close(); } public static void playtrainwarning(){ trainalert.setframeposition(0); trainalert.start(); } public static void stoptrainwarning(){ trainalert.stop(); trainalert.close(); } public static void playbirdgo(){ birdgo.setframeposition(0); birdgo.start(); } public static void playcoinp(){ coinp.setframeposition(0); coinp.start(); } public static void playgameover(){ gameover.setframeposition(0); gameover.start(); } }
it works within netbeans no errors whatsoever, sucessfully compiles jar file noticed error command prompt cause didn't want open double clicking it? has experienced error? if so, how did manage load sound assets jar file? tips/advices highly appreciated time!
Comments
Post a Comment