Now if I swap the code back to SoundSystem.create3DSample(url) it works just fine, but when I switch it back it stops working. Is there something extra I need to do here?
update and draw doesnt really apply to a stream…neither does maxaudibledistance, setcamera, addsample etc, they apply only to sample3d's which are created by the createSample method…
this is all you need to do to kickstart a stream:
URL rootUrl = getClass().getClassLoader().getResource("("/data/music/beat_plus.ogg");
log.debug("Trying to load streaming background ...");
background = SoundSystem.createStream(rootUrl);
if(SoundSystem.isStreamOpened(background)) {
int lgth = (int) SoundSystem.getStreamLength(background);
log.debug("Stream background loaded! Music length:" + lgth);
SoundSystem.playStream(background);
}
else {
log.debug("Failed to open stream!");
}
Great job! I'm sure you're getting sick of me by now, but when the stream was finished and I would think should have looped (I tried to enable looping) I got this exception:
Exception in thread "Thread-9" java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at com.jmex.sound.openAL.objects.util.StreamPlayer.reopenOgg(StreamPlayer.java:122)
at com.jmex.sound.openAL.objects.util.StreamPlayer.open(StreamPlayer.java:103)
at com.jmex.sound.openAL.objects.util.StreamPlayer.access$0(StreamPlayer.java:98)
at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.run(StreamPlayer.java:407)
at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.run(StreamPlayer.java:425)
at java.lang.Thread.run(Thread.java:595)
just looked through the code and i can see that you changed
tmp = new OggInputStream(file.openStream());
to
tmp = open(file.getFile(), true);
in StreamPlayer.java...
this just reverts the usage of the URL version to being the same as using createStream(/*string*/ url.getFile()), which brakes the reason i made the URL version all together...
url.openStream() is not the same as FileInputStream(url.getFile())...
I know but for the moment the files should be loaded locally… until I add the remote streaming capability…
The code you added does not load Wav files and it does not calculate the length of the stream…
For me it was a quick fix (more than I do quick fixes!!!) thats why I changed the code.
One question : Can someone tell me if you have seen any game loding sounds from a remote location?
As I always see the files are loaded locally in any game…This may be because of network lag… And not everybody has a dsl connection in networked games…
Yeah, that's why I need URL loading as well. The way Arman did it is fine when I'm developing, but when I release I plan on keeping the music in JAR files.