public class StreamPlayer
extends java.lang.Object
implements java.util.concurrent.Callable<java.lang.Void>
| Constructor and Description |
|---|
StreamPlayer()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addStreamPlayerListener(StreamPlayerListener streamPlayerListener)
Add a listener to be notified.
|
java.lang.Void |
call()
Main loop.
|
float |
getBalance()
Return the balance Value.
|
int |
getDurationInSeconds() |
int |
getEncodedStreamPosition()
Calculates the current position of the encoded audio based on
nEncodedBytes = encodedAudioLength - encodedAudioInputStream.available(); |
float |
getGainValue()
Returns Gain value.
|
int |
getLineBufferSize()
Return SourceDataLine buffer size.
|
int |
getLineCurrentBufferSize()
Return SourceDataLine current buffer size.
|
float |
getMaximumGain()
Returns maximum Gain value.
|
float |
getMinimumGain()
Returns minimum Gain value.
|
java.util.List<java.lang.String> |
getMixers()
Returns all available mixers.
|
boolean |
getMute()
Return the mute Value(true || false).
|
float |
getPan()
Returns Pan value.
|
int |
getPositionByte() |
float |
getPrecision()
Returns Pan precision.
|
javax.sound.sampled.SourceDataLine |
getSourceDataLine()
Gets the source data line.
|
double |
getSpeedFactor() |
Status |
getStatus()
This method will return the status of the player
|
long |
getTotalBytes()
Return the total size of this file in bytes.
|
boolean |
isOpened()
Checks if is opened.
|
boolean |
isPaused()
Checks if is paused.
|
boolean |
isPausedOrPlaying()
Checks if is paused or playing.
|
boolean |
isPlaying()
Checks if is playing.
|
boolean |
isSeeking()
Checks if is seeking.
|
boolean |
isStopped()
Checks if is stopped.
|
boolean |
isUnknown()
Checks if is unknown.
|
void |
open(java.lang.Object object)
Open the specific object which can be File,URL or InputStream.
|
boolean |
pause()
Pauses the play back.
|
void |
play()
Starts the play back.
|
void |
removeStreamPlayerListener(StreamPlayerListener streamPlayerListener)
Remove registered listener.
|
void |
reset()
Freeing the resources.
|
boolean |
resume()
Resumes the play back.
|
long |
seekBytes(long bytes)
Skip bytes in the File input stream.
|
long |
seekSeconds(int seconds)
Skip x seconds of audio
See
seekBytes(long) |
long |
seekTo(int seconds)
Go to X time of the Audio
See
seekBytes(long) |
void |
setBalance(float fBalance)
Represents a control for the relative balance of a stereo signal between two
stereo speakers.
|
void |
setEqualizer(float[] array,
int stop)
Changes specific values from equalizer.
|
void |
setEqualizerKey(float value,
int key)
Changes a value from equalizer.
|
void |
setGain(double fGain)
Sets Gain value.
|
void |
setLineBufferSize(int size)
Set SourceDataLine buffer size.
|
void |
setMute(boolean mute)
Set the mute of the Line.
|
void |
setPan(double fPan)
Sets Pan value.
|
void |
setSpeedFactor(double speedFactor)
Change the Speed Rate of the Audio , this variable affects the Sample Rate ,
for example 1.0 is normal , 0.5 is half the speed and 2.0 is double the speed
Note that you have to restart the audio for this to take effect
|
void |
stop()
Stops the play back.
|
public void reset()
public void addStreamPlayerListener(StreamPlayerListener streamPlayerListener)
streamPlayerListener - the listenerpublic void removeStreamPlayerListener(StreamPlayerListener streamPlayerListener)
streamPlayerListener - the listenerpublic void open(java.lang.Object object)
throws StreamPlayerException
object - the object [File or URL or InputStream ]StreamPlayerException - the stream player exceptionpublic void setSpeedFactor(double speedFactor)
speedFactor - speedFactorpublic void play()
throws StreamPlayerException
StreamPlayerException - the stream player exceptionpublic boolean pause()
Player Status = PAUSED. * @return False if failed(so simple...)
public void stop()
Player Status = STOPPED.
Thread should free Audio resources.
public boolean resume()
Player Status = PLAYING*
public long seekBytes(long bytes)
throws StreamPlayerException
bytes - the bytesStreamPlayerException - the stream player exceptionpublic long seekSeconds(int seconds)
throws java.lang.Exception
seekBytes(long)seconds - Seconds to Skipjava.lang.Exceptionpublic long seekTo(int seconds)
throws java.lang.Exception
seekBytes(long)seconds - Seconds to Skipjava.lang.Exceptionpublic int getDurationInSeconds()
public java.lang.Void call()
Player Status == STOPPED || SEEKING = End of Thread + Freeing Audio
Resources.
Player Status == PLAYING = Audio stream data sent to Audio line.
Player Status == PAUSED = Waiting for another status.
call in interface java.util.concurrent.Callable<java.lang.Void>public int getEncodedStreamPosition()
public int getLineBufferSize()
public int getLineCurrentBufferSize()
public java.util.List<java.lang.String> getMixers()
public float getGainValue()
public float getMaximumGain()
public float getMinimumGain()
public float getPrecision()
public float getPan()
public boolean getMute()
public float getBalance()
public long getTotalBytes()
public int getPositionByte()
public javax.sound.sampled.SourceDataLine getSourceDataLine()
public Status getStatus()
public void setLineBufferSize(int size)
size - -1 means maximum buffer size available.public void setPan(double fPan)
fPan - the new panpublic void setGain(double fGain)
fGain - The new gain valuepublic void setMute(boolean mute)
mute - True to mute the audio of False to unmute itpublic void setBalance(float fBalance)
fBalance - the new balancepublic void setEqualizer(float[] array,
int stop)
array - the arraystop - the stoppublic void setEqualizerKey(float value,
int key)
value - the valuekey - the keypublic double getSpeedFactor()
public boolean isUnknown()
public boolean isPlaying()
public boolean isPaused()
public boolean isPausedOrPlaying()
public boolean isStopped()
public boolean isOpened()
public boolean isSeeking()
Copyright © 2019. All rights reserved.