Thread View: borland.public.jbuilder.java.language
1 messages
1 total messages
Started by LMario
Fri, 26 Aug 2005 03:30
Sound
Author: LMario
Date: Fri, 26 Aug 2005 03:30
Date: Fri, 26 Aug 2005 03:30
40 lines
1802 bytes
1802 bytes
I am playing a sound. How can I know when the sound terninates of playing. I
am using the next class on my program:
--------------------------------------
import java.io.*;
import javax.sound.sampled.*;
public class Sound {
File sf=new File("mySound.wav");
AudioFileFormat aff;
AudioInputStream ais;
public Sound() {
try {
aff = AudioSystem.getAudioFileFormat(sf);
//System.out.println(aff);
ais = AudioSystem.getAudioInputStream(sf);
AudioFormat af = aff.getFormat();
DataLine.Info info = new DataLine.Info(
Clip.class,
ais.getFormat(),
( (int) ais.getFrameLength() *
af.getFrameSize()));
Clip ol = (Clip) AudioSystem.getLine(info);
ol.open(ais);
ol.loop(3);
}
catch (UnsupportedAudioFileException ee) {}
catch (IOException ea) {}
catch (LineUnavailableException LUE) {}
System.out.println("Error") ;
}
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads