public class JDK13LongAudioClip extends Object implements LoopableAudioClip, Runnable
LOOP_CONTINUOUSLY| Constructor and Description |
|---|
JDK13LongAudioClip(byte[] samples,
int sampleRate,
int volume,
float pan)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getMicrosecondLength()
Obtains the media duration in microseconds
|
long |
getMicrosecondPosition()
Obtains the current position in the audio data, in microseconds.
|
void |
loop()
Starts playing this audio clip in a loop.
|
void |
loop(int count)
Starts looping playback from the current position.
|
void |
play()
Starts playing this audio clip.
|
void |
run()
When an object implementing interface
Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread. |
void |
setFramePosition(int param)
Sets the media position in sample frames.
|
void |
setLoopPoints(int start,
int end)
Sets the first and last sample frames that will be played in
the loop.
|
void |
start()
Starts the audio clip.
|
void |
stop()
Stops playing this audio clip.
|
public JDK13LongAudioClip(byte[] samples,
int sampleRate,
int volume,
float pan)
samples - Array of signed linear 8-bit encoded audio samples.sampleRate - sampleRate of the audio samples.volume - The volume setting controls the loudness of the sound.
range 0 (mute) to 64 (maximal volume).pan - The relative pan of a stereo signal between two stereo
speakers. The valid range of values is -1.0 (left channel only) to 1.0
(right channel only). The default is 0.0 (centered).public void loop()
public void loop(int count)
count times, and finally continue playback to the end of
the clip.
If the current position when this method is invoked is greater than the loop end point, playback simply continues to the end of the clip without looping.
A count value of 0 indicates that any current looping should
cease and playback should continue to the end of the clip. The behavior
is undefined when this method is invoked with any other value during a
loop operation.
If playback is stopped during looping, the current loop status is cleared; the behavior of subsequent loop and start requests is not affected by an interrupted loop operation.
loop in interface LoopableAudioClipcount - the number of times playback should loop back from the
loop's end position to the loop's start position, or
LoopableAudioClip.LOOP_CONTINUOUSLY to indicate that looping should
continue until interruptedpublic void play()
public void start()
public void setFramePosition(int param)
To obtain the current position in sample frames, use the
method of getFramePositionDataLine.
param - the desired new media position, expressed in sample framespublic long getMicrosecondLength()
AudioSystem.NOT_SPECIFIED if the line is not open.AudioSystem.NOT_SPECIFIEDpublic long getMicrosecondPosition()
public void setLoopPoints(int start,
int end)
start - the loop's starting position, in sample frames (zero-based)end - the loop's ending position, in sample frames (zero-based), or
-1 to indicate the final frameIllegalArgumentException - if the requested
loop points cannot be set, usually because one or both falls outside
the media's duration or because the ending point is
before the starting pointpublic void run()
Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread.
The general contract of the method run is that it may
take any action whatsoever.
run in interface RunnableThread.run()Copyright © 2014. All Rights Reserved.