Does anyone know how to play a sound file just one time using JASS? I can play sound using SourcePlayer but this is a thread and it plays over and over again.
I am using the code below:
SourcePlayer player;
LoopBuffer loopbuffer;
Mixer mixer;
String wavfile = "sounds/ur.wav";
public void start(int speed) {
float srate = 44100.f;
int bufferSize = 128*4;
int bufferSizeJavaSound = 8*1024;
loopbuffer = new LoopBuffer(srate, bufferSize, wavfile);
mixer = new Mixer(bufferSize, 1);
mixer.setGain(0,1);
player = new SourcePlayer(bufferSize, bufferSizeJavaSound, srate);
try {
player.addSource(mixer);
mixer.addSource(loopbuffer);
} catch(SinkIsFullException e) { }
float val = (float)(.95 + speed/20.);
loopbuffer.setSpeed((float)val);
player.start();
}
Thanks in advance
I have not used JAAS but you can comfortably play *.wav file using the javax.sound package,the snippet is as below:
hope this helps…happy Coding