|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
javax.sound.sampled
|
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface javax.sound.sampled.DataLine |
---|
DataLine.Info |
Field Summary | |
---|---|
static int |
LOOP_CONTINUOUSLY
A value indicating that looping should continue indefinitely rather than complete after a specific number of loops. |
Method Summary | |
---|---|
int |
getFrameLength()
Obtains the media length in sample frames. |
long |
getMicrosecondLength()
Obtains the media duration in microseconds |
void |
loop(int count)
Starts looping playback from the current position. |
void |
open(AudioFormat format,
byte[] data,
int offset,
int bufferSize)
Opens the clip, meaning that it should acquire any required system resources and become operational. |
void |
open(AudioInputStream stream)
Opens the clip with the format and audio data present in the provided audio input stream. |
void |
setFramePosition(int frames)
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 |
setMicrosecondPosition(long microseconds)
Sets the media position in microseconds. |
Methods inherited from interface javax.sound.sampled.DataLine |
---|
available, drain, flush, getBufferSize, getFormat, getFramePosition, getLevel, getLongFramePosition, getMicrosecondPosition, isActive, isRunning, start, stop |
Methods inherited from interface javax.sound.sampled.Line |
---|
addLineListener, close, getControl, getControls, getLineInfo, isControlSupported, isOpen, open, removeLineListener |
Field Detail |
---|
static final int LOOP_CONTINUOUSLY
loop(int)
,
Constant Field ValuesMethod Detail |
---|
void open(AudioFormat format, byte[] data, int offset, int bufferSize) throws LineUnavailableException
OPEN
event is dispatched
to the line's listeners.
Invoking this method on a line which is already open is illegal and may result in an IllegalStateException.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in a
.
LineUnavailableException
format
- the format of the supplied audio datadata
- a byte array containing audio data to load into the clipoffset
- the point at which to start copying, expressed in
bytes from the beginning of the arraybufferSize
- the number of bytes
of data to load into the clip from the array.
LineUnavailableException
- if the line cannot be
opened due to resource restrictions
IllegalArgumentException
- if the buffer size does not represent
an integral number of sample frames,
or if format
is not fully specified or invalid
IllegalStateException
- if the line is already open
SecurityException
- if the line cannot be
opened due to security restrictionsLine.close()
,
Line.isOpen()
,
LineListener
void open(AudioInputStream stream) throws LineUnavailableException, IOException
OPEN
event is dispatched
to the line's listeners.
Invoking this method on a line which is already open is illegal and may result in an IllegalStateException.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in a
.
LineUnavailableException
stream
- an audio input stream from which audio data will be read into
the clip
LineUnavailableException
- if the line cannot be
opened due to resource restrictions
IOException
- if an I/O exception occurs during reading of
the stream
IllegalArgumentException
- if the stream's audio format
is not fully specified or invalid
IllegalStateException
- if the line is already open
SecurityException
- if the line cannot be
opened due to security restrictionsLine.close()
,
Line.isOpen()
,
LineListener
int getFrameLength()
AudioSystem.NOT_SPECIFIED
if the line is not open.AudioSystem.NOT_SPECIFIED
long getMicrosecondLength()
AudioSystem.NOT_SPECIFIED
if the line is not open.AudioSystem.NOT_SPECIFIED
void setFramePosition(int frames)
To obtain the current position in sample frames, use the
method of getFramePosition
DataLine
.
frames
- the desired new media position, expressed in sample framesvoid setMicrosecondPosition(long microseconds)
To obtain the current position in microseconds, use the
method of getMicrosecondPosition
DataLine
.
microseconds
- the desired new media position, expressed in microsecondsvoid 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 frame
IllegalArgumentException
- 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 pointvoid 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.
count
- the number of times playback should loop back from the
loop's end position to the loop's start position, or
LOOP_CONTINUOUSLY
to indicate that looping should
continue until interrupted