Package ipsk.audio.player
Class Player
- java.lang.Object
-
- ipsk.audio.player.Player
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.EventListener
,javax.sound.sampled.LineListener
- Direct Known Subclasses:
AudioClipPlayer
public class Player extends java.lang.Object implements java.lang.Runnable, javax.sound.sampled.LineListener
Audio player.- Author:
- klausj
-
-
Field Summary
Fields Modifier and Type Field Description protected UpdateAWTEventTransferAgent<PlayerListener,PlayerEvent>
apETA
protected AudioSource
audioSource
protected static int
DEF_PREFERRED_BUFFER_SIZE
protected static int
THREAD_INTERRUPT_TIMEOUT
-
Constructor Summary
Constructors Constructor Description Player()
Player(AudioSource audioSource)
Player(java.io.File audioFile)
Player(java.net.URL audioURL)
Player(javax.sound.sampled.Mixer device)
Player(javax.sound.sampled.Mixer device, AudioSource audioSource)
Player(javax.sound.sampled.Mixer device, java.io.File audioFile)
Player(javax.sound.sampled.Mixer device, java.net.URL audioURL)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPlayerListener(PlayerListener pl)
void
close()
javax.sound.sampled.AudioFormat
getAudioFormat()
AudioSource
getAudioSource()
int
getBufferSize()
int
getChannelOffset()
ChannelRouting
getChannelRouting()
long
getFrameLength()
long
getFramePosition()
LevelInfo[]
getLevelInfos()
javax.sound.sampled.SourceDataLine
getLine()
int
getPreferredBufferSize()
java.lang.Integer
getPreferredLineBufferSize()
java.lang.Float
getPreferredLineBufferSizeMillis()
long
getStartFramePosition()
long
getStopFramePosition()
boolean
isAvoidWriteLock()
boolean
isForceOpening()
boolean
isFormatSupported(javax.sound.sampled.AudioFormat af)
boolean
isLooping()
boolean
isMeasureLevel()
boolean
isOpen()
boolean
isPaused()
boolean
isPlaying()
boolean
isUseAWTEventThread()
static void
main(java.lang.String[] args)
void
open()
void
pause()
void
play()
void
removePlayerListener(PlayerListener pl)
void
resetPeakHold()
void
run()
void
setAudioSource(AudioSource audioSource)
void
setAvoidWriteLock(boolean avoidWriteLock)
void
setChannelOffset(int channelOffset)
void
setChannelRouting(ChannelRouting channelRouting)
void
setForceOpening(boolean forceOpening)
long
setFramePosition(long pos)
void
setLooping(boolean looping)
void
setMeasureLevel(boolean measureLevel)
void
setMixer(javax.sound.sampled.Mixer newPlaybackMixer)
void
setPeakLevelHold(float[] peakLevels)
void
setPreferredBufferSize(int preferredBufferSize)
void
setPreferredLineBufferSize(java.lang.Integer preferredLineBufferSize)
void
setPreferredLineBufferSizeMillis(java.lang.Float preferredLineBufferSizeMillis)
void
setSelection(long startFramePosition, long stopFramePosition)
void
setStartFramePosition(long startFramePosition)
void
setStopFramePosition(long stopFramePosition)
void
setUseAWTEventThread(boolean useAWTEventThread)
void
start()
void
stop()
void
update(javax.sound.sampled.LineEvent event)
-
-
-
Field Detail
-
DEF_PREFERRED_BUFFER_SIZE
protected static final int DEF_PREFERRED_BUFFER_SIZE
- See Also:
- Constant Field Values
-
THREAD_INTERRUPT_TIMEOUT
protected static final int THREAD_INTERRUPT_TIMEOUT
- See Also:
- Constant Field Values
-
apETA
protected UpdateAWTEventTransferAgent<PlayerListener,PlayerEvent> apETA
-
audioSource
protected AudioSource audioSource
-
-
Constructor Detail
-
Player
public Player()
-
Player
public Player(javax.sound.sampled.Mixer device)
-
Player
public Player(AudioSource audioSource)
-
Player
public Player(java.io.File audioFile)
-
Player
public Player(java.net.URL audioURL)
-
Player
public Player(javax.sound.sampled.Mixer device, AudioSource audioSource)
-
Player
public Player(javax.sound.sampled.Mixer device, java.io.File audioFile)
-
Player
public Player(javax.sound.sampled.Mixer device, java.net.URL audioURL)
-
-
Method Detail
-
isPlaying
public boolean isPlaying()
-
isPaused
public boolean isPaused()
-
setAudioSource
public void setAudioSource(AudioSource audioSource) throws PlayerException
- Throws:
PlayerException
-
isFormatSupported
public boolean isFormatSupported(javax.sound.sampled.AudioFormat af)
-
open
public void open() throws PlayerException
- Throws:
PlayerException
-
start
public void start()
-
play
public void play() throws PlayerException
- Throws:
PlayerException
-
getFrameLength
public long getFrameLength()
-
setFramePosition
public long setFramePosition(long pos) throws PlayerException
- Throws:
PlayerException
-
pause
public void pause()
-
stop
public void stop()
-
close
public void close() throws PlayerException
- Throws:
PlayerException
-
getFramePosition
public long getFramePosition()
-
getLevelInfos
public LevelInfo[] getLevelInfos()
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
isOpen
public boolean isOpen()
-
addPlayerListener
public void addPlayerListener(PlayerListener pl)
-
removePlayerListener
public void removePlayerListener(PlayerListener pl)
-
getStartFramePosition
public long getStartFramePosition()
-
setStartFramePosition
public void setStartFramePosition(long startFramePosition)
-
getStopFramePosition
public long getStopFramePosition()
-
setStopFramePosition
public void setStopFramePosition(long stopFramePosition)
-
setSelection
public void setSelection(long startFramePosition, long stopFramePosition) throws PlayerException
- Throws:
PlayerException
-
isLooping
public boolean isLooping()
-
setLooping
public void setLooping(boolean looping)
-
getAudioFormat
public javax.sound.sampled.AudioFormat getAudioFormat()
-
setMixer
public void setMixer(javax.sound.sampled.Mixer newPlaybackMixer) throws PlayerException
- Throws:
PlayerException
-
getPreferredBufferSize
public int getPreferredBufferSize()
-
setPreferredBufferSize
public void setPreferredBufferSize(int preferredBufferSize)
-
getBufferSize
public int getBufferSize()
-
setPeakLevelHold
public void setPeakLevelHold(float[] peakLevels)
-
resetPeakHold
public void resetPeakHold()
-
getLine
public javax.sound.sampled.SourceDataLine getLine()
-
getAudioSource
public AudioSource getAudioSource()
-
isAvoidWriteLock
public boolean isAvoidWriteLock()
-
setAvoidWriteLock
public void setAvoidWriteLock(boolean avoidWriteLock)
-
getPreferredLineBufferSize
public java.lang.Integer getPreferredLineBufferSize()
-
setPreferredLineBufferSize
public void setPreferredLineBufferSize(java.lang.Integer preferredLineBufferSize)
-
getPreferredLineBufferSizeMillis
public java.lang.Float getPreferredLineBufferSizeMillis()
-
setPreferredLineBufferSizeMillis
public void setPreferredLineBufferSizeMillis(java.lang.Float preferredLineBufferSizeMillis)
-
isUseAWTEventThread
public boolean isUseAWTEventThread()
-
setUseAWTEventThread
public void setUseAWTEventThread(boolean useAWTEventThread)
-
isMeasureLevel
public boolean isMeasureLevel()
-
setMeasureLevel
public void setMeasureLevel(boolean measureLevel)
-
isForceOpening
public boolean isForceOpening()
-
setForceOpening
public void setForceOpening(boolean forceOpening)
-
getChannelRouting
public ChannelRouting getChannelRouting()
- Returns:
- the channelRouting
-
setChannelRouting
public void setChannelRouting(ChannelRouting channelRouting)
- Parameters:
channelRouting
- the channelRouting to set
-
getChannelOffset
public int getChannelOffset()
- Returns:
- the channelOffset
-
setChannelOffset
public void setChannelOffset(int channelOffset)
-
main
public static void main(java.lang.String[] args)
-
update
public void update(javax.sound.sampled.LineEvent event)
- Specified by:
update
in interfacejavax.sound.sampled.LineListener
-
-