Issues with OGG files in general

As mentioned in the following post (http://hub.jmonkeyengine.org/groups/sound/forum/topic/streaming-ogg-not-working-in-jme3-branch/) looping does not work with OGG streams.



Trying to stream multiple ogg files either crashes the entire application or simply stops the audio renderer. Here’s a sample of the code that makes the application crash:

[java]@Override

public void frame(final FrameUpdate f)

{

aTimeLeft -= f.aTpf;

if (aTimeLeft <= 0) {

final Song randomSong = (Song) MathUtils.getRandomElement(songList);

bgMusic = new AudioNode(aManager, “snd/” + randomSong.getName(), true);

aTimeLeft = randomSong.getLength();

aAudioRenderer.playSource(bgMusic);

}

}[/java]



The first song plays entirely, the second one plays for half a second and then the whole system crashes. I’ve put printlines after every statement and it appears that the crash occurs after the second time playSource is called.



Please note that this code works perfectly with WAV files.



Thank you.

I guess you are trying to start a new song when the previous one ends. I do this by looking at the status in my update loop:



[java]

public void simpleUpdate(float tpf)



if (music != null && music.getStatus() == AudioNode.Status.Stopped) {

playNextTrack();

}

[/java]



I suppose your problem is that, since it’s streaming, the length of time elapsed is not necessarily exactly the same as the track length. It shouldn’t crash though!



-davidc