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.LineListenerAudio player.- Author:
- klausj
-
-
Field Summary
Fields Modifier and Type Field Description protected UpdateAWTEventTransferAgent<PlayerListener,PlayerEvent>apETAprotected AudioSourceaudioSourceprotected static intDEF_PREFERRED_BUFFER_SIZEprotected static intTHREAD_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 voidaddPlayerListener(PlayerListener pl)voidclose()javax.sound.sampled.AudioFormatgetAudioFormat()AudioSourcegetAudioSource()intgetBufferSize()intgetChannelOffset()ChannelRoutinggetChannelRouting()longgetFrameLength()longgetFramePosition()LevelInfo[]getLevelInfos()javax.sound.sampled.SourceDataLinegetLine()intgetPreferredBufferSize()java.lang.IntegergetPreferredLineBufferSize()java.lang.FloatgetPreferredLineBufferSizeMillis()longgetStartFramePosition()longgetStopFramePosition()booleanisAvoidWriteLock()booleanisForceOpening()booleanisFormatSupported(javax.sound.sampled.AudioFormat af)booleanisLooping()booleanisMeasureLevel()booleanisOpen()booleanisPaused()booleanisPlaying()booleanisUseAWTEventThread()static voidmain(java.lang.String[] args)voidopen()voidpause()voidplay()voidremovePlayerListener(PlayerListener pl)voidresetPeakHold()voidrun()voidsetAudioSource(AudioSource audioSource)voidsetAvoidWriteLock(boolean avoidWriteLock)voidsetChannelOffset(int channelOffset)voidsetChannelRouting(ChannelRouting channelRouting)voidsetForceOpening(boolean forceOpening)longsetFramePosition(long pos)voidsetLooping(boolean looping)voidsetMeasureLevel(boolean measureLevel)voidsetMixer(javax.sound.sampled.Mixer newPlaybackMixer)voidsetPeakLevelHold(float[] peakLevels)voidsetPreferredBufferSize(int preferredBufferSize)voidsetPreferredLineBufferSize(java.lang.Integer preferredLineBufferSize)voidsetPreferredLineBufferSizeMillis(java.lang.Float preferredLineBufferSizeMillis)voidsetSelection(long startFramePosition, long stopFramePosition)voidsetStartFramePosition(long startFramePosition)voidsetStopFramePosition(long stopFramePosition)voidsetUseAWTEventThread(boolean useAWTEventThread)voidstart()voidstop()voidupdate(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:
runin 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:
updatein interfacejavax.sound.sampled.LineListener
-
-