|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.groovemanager.sampled.AudioPlayer
This class can be used for playing or recording Audio data in a new Thread.
| Nested Class Summary | |
|---|---|
private class |
AudioPlayer.OneLoop
A helper class for calculation if the current play position |
| Field Summary | |
|---|---|
protected int |
actualLength
The number of frames currently read from the last provided AudioInputStream. |
protected java.util.ArrayList |
aisLengths
List containing an OneLoop instances for each complete read AudioInputStream during this playback phase. |
protected AudioManager |
audioManager
The AudioManager. used for getting the selected in and out Mixers |
protected int |
bufferSize
The buffer size to be used when opening lines. |
protected ConfigManager |
configManager
The ConfigManager. |
protected boolean |
cont
Break condition for the play/record Thread |
static int |
CONTINUED
Possible values for status changes |
protected boolean |
endReached
Flag indicating if the Thread has already been requested to stop. |
protected javax.sound.sampled.AudioInputStream |
in
The stream from which data is read |
protected int |
lastStart
The start position of the last provided AudioInputStream. |
protected java.util.ArrayList |
listeners
The List of registered AudioPlayerListeners |
protected boolean |
loop
Flag indicating if the playback should be looped or not |
static int |
NOT_READY
Possible values for player status |
static int |
PAUSE_PLAY
Possible values for player status |
static int |
PAUSE_REC
Possible values for player status |
static int |
PAUSED
Possible values for status changes |
private java.lang.Thread |
playAndRecordThread
Thread for playback and recording |
static int |
PLAYING
Possible values for player status |
protected int |
priority
The thread priority to be assigned to the play/rec threads |
protected AudioPlayerProvider |
provider
The AudioPlayerProvider which provides thsi player with audio data and receives recorded audio data if capable for recording |
static int |
PROVIDER_REMOVED
Possible values for status changes |
static int |
PROVIDER_SET
Possible values for status changes |
protected byte[] |
readBuffer
The byte[] buffer used for reading and writing audio data |
static int |
READY_FOR_PLAY
Possible values for player status |
static int |
READY_FOR_REC
Possible values for player status |
static int |
RECORDING
Possible values for player status |
protected javax.sound.sampled.SourceDataLine |
sourceLine
Audio output line |
static int |
STARTED
Possible values for status changes |
protected int |
status
The current player status |
protected boolean |
stopped
Tells if the stop method has been invoked |
static int |
STOPPED
Possible values for status changes |
protected javax.sound.sampled.AudioFormat |
targetFormat
The AudioFormat in which the Audio data must be written to the line (in play situations) or to the provider (in rec situations) |
protected javax.sound.sampled.TargetDataLine |
targetLine
Audio input line |
| Constructor Summary | |
|---|---|
AudioPlayer()
Constructs a new AudioPlayer using the default ConfigManager and the default Audiomanager |
|
AudioPlayer(ConfigManager configManager)
Constructs a new AudioPlayer using the given ConfigManager and a new AudioManager using this ConfigManager too |
|
AudioPlayer(ConfigManager configManager,
AudioManager audioManager)
Constructs a new AudioPlayer using the given ConfigManager and AudioManager |
|
| Method Summary | |
|---|---|
void |
addAudioPlayerListener(AudioPlayerListener listener)
Register an AudioPlayerListener |
void |
cont()
Continue playback or recording after pause |
protected javax.sound.sampled.DataLine |
createLine(javax.sound.sampled.AudioFormat format,
boolean isTarget)
Get the line from the currently selected Mixer that best supports the specified AudioFormat |
protected void |
end()
Tell the Thread that it should come to its end. |
protected void |
freeRessources()
Free all ressources |
int |
getBufferFillLevel()
Gets the fill level of the line“s buffer |
int |
getFramePosition()
Get the current position inside audio source considering passed loops and the startPosition provided by the AudioPlayerProvider |
boolean |
getLoop()
Tell if the player is currently in loop mode or not |
AudioPlayerProvider |
getProvider()
Get the currently assigned AudioPlayerProvider |
int |
getRealBufferSize()
Ask for the real buffer size used by the line |
javax.sound.sampled.AudioFormat |
getRealFormat()
Get the AudioFormat which the currently active Line is using. |
int |
getStatus()
Get the current status |
static java.lang.String |
getStatusName(int status)
Get a String description of the given player status |
protected static javax.sound.sampled.AudioFormat |
getUsableFormat(javax.sound.sampled.DataLine line,
javax.sound.sampled.AudioFormat sourceFormat,
boolean isTarget)
Tries to get an AudioFormat which is supported by the line and is as near as possible to the specified sourceFormat |
protected static boolean |
isFormatComplete(javax.sound.sampled.AudioFormat format)
Checks if the given AudioFormat is fully specified and doesn't contain any AudioSystem.NOT_SPECIFIED values |
private void |
notifyListeners(int type)
Notify all registered listeners about a status change |
private void |
notifyListenersLoop(boolean loop)
Notify all registered listeners about a loop change |
void |
pause()
Pause playback or recording, but stay prepared for immediate continuing |
void |
play()
Start playback |
void |
propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
React to changes of the buffer size |
void |
rec()
Start recording |
void |
removeAudioPlayerListener(AudioPlayerListener listener)
Remove a registered AudioPlayerListener |
void |
removeProvider()
Remove the AudioPlayerProvider |
void |
run()
|
void |
setLoop(boolean loop)
Enable or disable looping |
void |
setPriority(int p)
Set the priority of the playback/record Thread. |
void |
setProvider(AudioPlayerProvider p)
Set the provider, which provides the data for playing and - if supported - processes recorded data |
void |
stop()
Stop recording or playback |
void |
switchLoop()
Switch the current loop state |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int actualLength
protected java.util.ArrayList aisLengths
protected AudioManager audioManager
protected int bufferSize
protected ConfigManager configManager
protected boolean cont
public static final int CONTINUED
protected boolean endReached
protected javax.sound.sampled.AudioInputStream in
protected int lastStart
protected java.util.ArrayList listeners
protected boolean loop
public static final int NOT_READY
public static final int PAUSE_PLAY
public static final int PAUSE_REC
public static final int PAUSED
private java.lang.Thread playAndRecordThread
public static final int PLAYING
protected int priority
protected AudioPlayerProvider provider
public static final int PROVIDER_REMOVED
public static final int PROVIDER_SET
protected byte[] readBuffer
public static final int READY_FOR_PLAY
public static final int READY_FOR_REC
public static final int RECORDING
protected javax.sound.sampled.SourceDataLine sourceLine
public static final int STARTED
protected int status
protected boolean stopped
public static final int STOPPED
protected javax.sound.sampled.AudioFormat targetFormat
protected javax.sound.sampled.TargetDataLine targetLine
| Constructor Detail |
|---|
public AudioPlayer()
public AudioPlayer(ConfigManager configManager)
configManager - The ConfigManager to be used
public AudioPlayer(ConfigManager configManager,
AudioManager audioManager)
configManager - The ConfigManager to be usedaudioManager - The AudioManager to be used| Method Detail |
|---|
public void addAudioPlayerListener(AudioPlayerListener listener)
listener - The AudioPlayerListener
public void cont()
throws NotReadyException
NotReadyException
protected javax.sound.sampled.DataLine createLine(javax.sound.sampled.AudioFormat format,
boolean isTarget)
throws javax.sound.sampled.LineUnavailableException
format - The wished AudioFormat. Will also return a
Line if the Format doesn't match.isTarget - true if an Input Line (TargetdataLine) is
wanted, false for an output Line (SourceDataLine)
javax.sound.sampled.LineUnavailableException - if the requestes ressources
are not availableprotected void end()
protected void freeRessources()
public int getBufferFillLevel()
public int getFramePosition()
public boolean getLoop()
public AudioPlayerProvider getProvider()
public int getRealBufferSize()
public javax.sound.sampled.AudioFormat getRealFormat()
public int getStatus()
public static java.lang.String getStatusName(int status)
status - The player status
protected static javax.sound.sampled.AudioFormat getUsableFormat(javax.sound.sampled.DataLine line,
javax.sound.sampled.AudioFormat sourceFormat,
boolean isTarget)
line - The Line which has to support the FormatsourceFormat - A hint how the resulting Format should
be like if possibleisTarget - Specifies if we are talking about a Target
line or not. This is important to find the best matching format.
protected static boolean isFormatComplete(javax.sound.sampled.AudioFormat format)
format - The Format to be checked
private void notifyListeners(int type)
type - The type of status changeprivate void notifyListenersLoop(boolean loop)
loop - The new loop statepublic void pause()
public void play()
throws NotReadyException,
javax.sound.sampled.LineUnavailableException
NotReadyException - if the Player or the provider are not
ready for playback or if playback is already active
javax.sound.sampled.LineUnavailableException - if the needed ressources are not
availablepublic void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListenerIPropertyChangeListener.propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
public void rec()
throws NotReadyException,
javax.sound.sampled.LineUnavailableException
NotReadyException - if the recorder or the provider is not ready
javax.sound.sampled.LineUnavailableException - if the needed ressources are not
availablepublic void removeAudioPlayerListener(AudioPlayerListener listener)
listener - The AudioPlayerListenerpublic void removeProvider()
public void run()
run in interface java.lang.RunnableRunnable.run()public void setLoop(boolean loop)
loop - true if looping should be turned on, false otherwisepublic void setPriority(int p)
p - The new priority. Values between
Thread.MIN_PRIORITY and Thread.MAX_PRIORITY are
acceptedpublic void setProvider(AudioPlayerProvider p)
p - The AudioPlayerProviderpublic void stop()
public void switchLoop()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||