Jar with compressed music with java? -
i've tried add music application i've made. first tried .wav
files though became huge application became large upload anywhere.
so changed files .mp3
, tried jmf
, jlayer
though both of them won't work on runnable jars (even if work fine when haven't exported them).
so got tips on how play compressed music runnable jar?
here's code jlayer, when exported stops working @ f = new file(u.touri())
without throwing exceptions...
try { url u = cl.getresource("new beginnings.mp3"); f = new file(u.touri()); } catch (urisyntaxexception e1) { e1.printstacktrace(); } try { fileinputstream fis = new fileinputstream(f); p = new player(fis); p.play(); } catch (exception e) { system.out.println(e); }
edit: fixed changing above code to:
try { inputstream fis = classloader.getsystemclassloader().getresourceasstream(temp+".mp3"); p = new player(fis); p.play(); } catch (exception e) { system.out.println(e); }
where did place sound file exactly?
you should create new package inside project , place resources there, read file sending complete path:
ex. create new package called sounds, then:
inputstream fis = classloader.getsystemclassloader().getresourceasstream("/sounds/"+temp+".mp3"); p = new player(fis); p.play();
to honest, didn't try sounds, problem happened me when used images. placed them in package, , worked fine..
Comments
Post a Comment