public class IstiSound
extends java.lang.Object
implements javax.sound.sampled.LineListener, java.awt.event.ActionListener
| Modifier and Type | Field and Description |
|---|---|
protected javax.sound.sampled.Clip |
clipObj |
protected long |
stopPlayTimeVal |
| Constructor and Description |
|---|
IstiSound(javax.sound.sampled.AudioInputStream audiosource)
Creates a sound from the specified audio input stream.
|
IstiSound(java.io.File file)
Creates a sound from the specified sound file.
|
IstiSound(java.io.InputStream stmObj)
Creates a sound from the specified input stream.
|
IstiSound(java.net.URL url)
Creates a sound from the specified sound file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Supports the ActionListener interface.
|
void |
close()
Release resources associated with this sound object.
|
boolean |
isActive()
Checks if a sound is active
|
boolean |
isOpen()
Queries whether or not this sound object is open.
|
static boolean |
isSoundFile(java.io.File file)
Checks if the specified file is a supported sound file.
|
static boolean |
isSoundFile(java.net.URL url)
Checks if the specified file is a supported sound file.
|
void |
loop()
Plays a sound continuously.
|
void |
loop(int count)
Plays a sound the specified number of times.
|
void |
play()
Plays a sound from start to finish.
|
void |
play(boolean waitFlag)
Plays a sound from start to finish.
|
void |
play(int secondsVal)
Plays a sound for the specified duration.
|
void |
reopen(javax.sound.sampled.AudioInputStream audiosource)
Reopens to use the sound from the specified audio input stream.
|
void |
reopen(java.io.File file)
Reopens to use the sound from the specified sound file.
|
void |
reopen(java.io.InputStream stmObj)
Reopens to use the sound from the specified input stream.
|
void |
reopen(java.net.URL url)
Reopens to use the sound from the specified sound file.
|
void |
reset()
Resets a sound to the beginning.
|
void |
start()
Starts or resumes playing a sound from the current position.
|
void |
stop()
Stops playing a sound.
|
void |
update(javax.sound.sampled.LineEvent lineEvent)
Supports the LineListener interface.
|
protected final javax.sound.sampled.Clip clipObj
protected long stopPlayTimeVal
public IstiSound(javax.sound.sampled.AudioInputStream audiosource)
throws java.io.IOException,
javax.sound.sampled.LineUnavailableException
audiosource - audio input streamjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionspublic IstiSound(java.io.File file)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException,
javax.sound.sampled.LineUnavailableException
file - the sound filejavax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a
valid sound file data recognized by the systemjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionsplaypublic IstiSound(java.net.URL url)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException,
javax.sound.sampled.LineUnavailableException
url - URL for the sound filejavax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a
valid sound file data recognized by the systemjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionsplaypublic IstiSound(java.io.InputStream stmObj)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException,
javax.sound.sampled.LineUnavailableException
stmObj - the input stream to use.javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a
valid sound file data recognized by the systemjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionsplaypublic void reopen(javax.sound.sampled.AudioInputStream audiosource)
throws java.io.IOException,
javax.sound.sampled.LineUnavailableException
audiosource - audio input streamjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available
due to resource restrictionspublic void reopen(java.io.File file)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException,
javax.sound.sampled.LineUnavailableException
file - the sound filejavax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a
valid sound file data recognized by the systemjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionsplaypublic void reopen(java.net.URL url)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException,
javax.sound.sampled.LineUnavailableException
url - URL for the sound filejavax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a
valid sound file data recognized by the systemjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionsplaypublic void reopen(java.io.InputStream stmObj)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException,
javax.sound.sampled.LineUnavailableException
stmObj - the input stream to use.javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a
valid sound file data recognized by the systemjava.io.IOException - if an I/O exception occursjavax.sound.sampled.LineUnavailableException - if a matching line is not available due
to resource restrictionsplaypublic static boolean isSoundFile(java.io.File file)
file - the sound filepublic static boolean isSoundFile(java.net.URL url)
url - URL for the sound filepublic boolean isActive()
public void loop()
public void loop(int count)
count - number of times to play the soundpublic void play(boolean waitFlag)
waitFlag - if true then this method blocks until the playing
of the sound is complete.reset, startpublic void play()
reset, startpublic void play(int secondsVal)
secondsVal - play duration in seconds.public void update(javax.sound.sampled.LineEvent lineEvent)
update in interface javax.sound.sampled.LineListenerlineEvent - line eventpublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenere - action event.public void reset()
public void start()
public void stop()
public void close()
public boolean isOpen()