I have a problem with my code where each time I run the project, this is thrown. Now I have narrowed it down to that the sound does play when I call the play() method but does not when I call the playL() method.
package net.chrypthic.Ball;
import sun.audio.*;
import java.io.*;
public class SoundManager {
AudioPlayer ap = AudioPlayer.player;
AudioStream as;
ContinuousAudioDataStream loop = null;
public SoundManager(String music)
{
try
{
InputStream input = new FileInputStream("./"+music);
as = new AudioStream(input);
AudioData ad = as.getData();
loop = new ContinuousAudioDataStream(ad);
}catch(Exception e)
{
System.out.println(e.getMessage());
}
}
public void play()
{
ap.start(as);
}
public void stop()
{
ap.start(as);
}
public void playL()
{
ap.start(loop);
}
public void stopL()
{
ap.start(loop);
}
}
Why? I pass sound/gsong1b.wav to it which has a size of 6.2MB, is 2 minutes long and has a bit rate of 16000Hz. I have heard that sounds have to be less that 4mb big but it plays, and only errors when I loop.... Any Help would be greatly appreciated.