|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.sound.SoundPlayer
public class SoundPlayer
SoundPlayer provides a convenient and simple way for playing back sampled audio and midi files, URLs, streams and midi sequences.
| Nested Class Summary | |
|---|---|
static interface |
SoundPlayer.Listener
This interface allows implementing classes to be notified when certain supported events by the SoundPlayer are triggered. |
| Field Summary | |
|---|---|
protected AudioInputStream |
audioStream
|
protected Clip |
clip
|
protected Object |
currentSoundSource
|
protected Sequence |
sequence
|
protected Sequencer |
sequencer
|
| Constructor Summary | |
|---|---|
SoundPlayer()
Initializes the SoundPlayer without loading any specific sound. |
|
SoundPlayer(File file)
|
|
SoundPlayer(InputStream stream)
accepts both midi and sampled audio streams |
|
SoundPlayer(Sequence sequence)
|
|
SoundPlayer(URL url)
|
|
| Method Summary | |
|---|---|
void |
addListener(SoundPlayer.Listener listener)
|
static void |
beep()
provides the standard beep sound |
void |
close()
closes the current sound. |
protected void |
finalize()
|
Object |
getCurrentSoundSource()
returned object may be of type InputStream, URL or File. |
long |
getMicrosecondLength()
if no active sound object is present, -1 is returned; note that this doesn't return milliseconds but microseconds; also, for sampled audio data, the length may be not accurate. |
long |
getMicrosecondPosition()
returns the current microsecond position of the active sound object; returns -1 if no active sound object present |
String |
getSongInfo()
returns the info for the current sound as a String to be displayed |
String |
getSoundTypeDescription()
|
boolean |
isPlaying()
|
void |
load(File file)
closes the existing data and then tries to load the given sound object |
protected void |
load(Object sound)
handles File and URL objects |
void |
load(SampleSounds sound)
|
void |
load(Sequence sq)
closes the existing data and then tries to load the given sound object |
void |
load(URL url)
closes the existing data and then tries to load the given sound object |
protected void |
notifyListeners()
|
void |
play()
if play() is called on a sound that has been
played through, you may have to call stop() before
play() will have the effect of replaying the sound |
static void |
play(URL url)
|
static void |
playAndWait(URL url)
|
void |
setMicrosecondPosition(long microseconds)
sets the microsecond position of the active sound object; the method call has no effect if no active sound object is present |
void |
stop()
use play() to resume playing after stop() was called |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Object currentSoundSource
protected AudioInputStream audioStream
protected Sequence sequence
protected Sequencer sequencer
protected Clip clip
| Constructor Detail |
|---|
public SoundPlayer()
throws SoundException
load(..) methods to
use that sound.
SoundException - if the midi sequencer is unavailable
public SoundPlayer(File file)
throws SoundException
SoundException
public SoundPlayer(URL url)
throws SoundException
SoundException
public SoundPlayer(InputStream stream)
throws SoundException
SoundException
public SoundPlayer(Sequence sequence)
throws SoundException
SoundException| Method Detail |
|---|
public static void beep()
public void load(Sequence sq)
throws SoundException
SoundException
public void load(URL url)
throws SoundException
SoundException
public void load(File file)
throws SoundException
SoundException
public void load(SampleSounds sound)
throws SoundException
SoundException
protected void load(Object sound)
throws SoundException
SoundExceptionpublic long getMicrosecondLength()
getMicrosecondPosition(),
setMicrosecondPosition(long)public long getMicrosecondPosition()
setMicrosecondPosition(long),
getMicrosecondLength()public void setMicrosecondPosition(long microseconds)
getMicrosecondPosition(),
getMicrosecondLength()public Object getCurrentSoundSource()
load(..) method)
public String getSoundTypeDescription()
public String getSongInfo()
public void close()
load(..) methods
public void play()
play() is called on a sound that has been
played through, you may have to call stop() before
play() will have the effect of replaying the sound
stop()public boolean isPlaying()
public void stop()
play()protected void finalize()
finalize in class Objectpublic void addListener(SoundPlayer.Listener listener)
protected void notifyListeners()
public static void play(URL url)
public static void playAndWait(URL url)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||