/*
* @(#)Clip.java 1.39 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.sound.sampled;
import java.io.InputStream;
import java.io.IOException;
/**
* The <code>Clip</code> interface represents a special kind of data line whose
* audio data can be loaded prior to playback, instead of being streamed in
* real time.
* <p>
* Because the data is pre-loaded and has a known length, you can set a clip
* to start playing at any position in its audio data. You can also create a
* loop, so that when the clip is played it will cycle repeatedly. Loops are
* specified with a starting and ending sample frame, along with the number of
* times that the loop should be played.
* <p>
* Clips may be obtained from a <code>{@link Mixer}</code> that supports lines
* of this type. Data is loaded into a clip when it is opened.
* <p>
* Playback of an audio clip may be started and stopped using the <code>start</code>
* and <code>stop</code> methods. These methods do not reset the media position;
* <code>start</code> causes playback to continue from the position where playback
* was last stopped. To restart playback from the beginning of the clip's audio
* data, simply follow the invocation of <code>{@link DataLine#stop stop}</code>
* with setFramePosition(0), which rewinds the media to the beginning
* of the clip.
*
* @author Kara Kytle
* @version 1.39, 05/11/17
* @since 1.3
*/
public interface Clip extends DataLine {
/**
* A value indicating that looping should continue indefinitely rather than
* complete after a specific number of loops.
* @see #loop
*/
public static final int LOOP_CONTINUOUSLY = -1;
/**
* Opens the clip, meaning that it should acquire any required
* system resources and become operational. The clip is opened
* with the format and audio data indicated.
* If this operation succeeds, the line is marked as open and an
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched
* to the line's listeners.
* <p>
* Invoking this method on a line which is already open is illegal
* and may result in an IllegalStateException.
* <p>
* Note that some lines, once closed, cannot be reopened. Attempts
* to reopen such a line will always result in a
* <code>{@link LineUnavailableException}</code>.
*
* @param format the format of the supplied audio data
* @param data a byte array containing audio data to load into the clip
* @param offset the point at which to start copying, expressed in
* <em>bytes</em> from the beginning of the array
* @param bufferSize the number of <em>bytes</em>
* of data to load into the clip from the array.
* @throws LineUnavailableException if the line cannot be
* opened due to resource restrictions
* @throws IllegalArgumentException if the buffer size does not represent
* an integral number of sample frames,
* or if <code>format</code> is not fully specified or invalid
* @throws IllegalStateException if the line is already open
* @throws SecurityException if the line cannot be
* opened due to security restrictions
*
* @see #close
* @see #isOpen
* @see LineListener
*/
public void open(AudioFormat format, byte[] data, int offset, int bufferSize) throws LineUnavailableException;
/**
* Opens the clip with the format and audio data present in the provided audio
* input stream. Opening a clip means that it should acquire any required
* system resources and become operational. If this operation
* input stream. If this operation
* succeeds, the line is marked open and an
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched
* to the line's listeners.
* <p>
* Invoking this method on a line which is already open is illegal
* and may result in an IllegalStateException.
* <p>
* Note that some lines, once closed, cannot be reopened. Attempts
* to reopen such a line will always result in a
* <code>{@link LineUnavailableException}</code>.
*
=1= |