📄 clip.html
字号:
<!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="open(javax.sound.sampled.AudioFormat, byte[], int, int)"><!-- --></A><H3>open</H3><PRE>public void <B>open</B>(<A HREF="../../../javax/sound/sampled/AudioFormat.html">AudioFormat</A> format, byte[] data, int offset, int bufferSize) throws <A HREF="../../../javax/sound/sampled/LineUnavailableException.html">LineUnavailableException</A></PRE><DL><DD>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><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#OPEN"><CODE>OPEN</CODE></A></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><A HREF="../../../javax/sound/sampled/LineUnavailableException.html"><CODE>LineUnavailableException</CODE></A></code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>format</CODE> - the format of the supplied audio data<DD><CODE>data</CODE> - a byte array containing audio data to load into the clip<DD><CODE>offset</CODE> - the point at which to start copying, expressed in <em>bytes</em> from the beginning of the array<DD><CODE>bufferSize</CODE> - the number of <em>bytes</em> of data to load into the clip from the array.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/sound/sampled/LineUnavailableException.html">LineUnavailableException</A></CODE> - if the line cannot be opened due to resource restrictions<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the buffer size does not represent an integral number of sample frames<DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if the line is already open<DD><CODE><A HREF="../../../java/lang/SecurityException.html">SecurityException</A></CODE> - if the line cannot be opened due to security restrictions<DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/Line.html#close()"><CODE>Line.close()</CODE></A>, <A HREF="../../../javax/sound/sampled/Line.html#isOpen()"><CODE>Line.isOpen()</CODE></A>, <A HREF="../../../javax/sound/sampled/LineListener.html"><CODE>LineListener</CODE></A></DL></DD></DL><HR><A NAME="open(javax.sound.sampled.AudioInputStream)"><!-- --></A><H3>open</H3><PRE>public void <B>open</B>(<A HREF="../../../javax/sound/sampled/AudioInputStream.html">AudioInputStream</A> stream) throws <A HREF="../../../javax/sound/sampled/LineUnavailableException.html">LineUnavailableException</A>, <A HREF="../../../java/io/IOException.html">IOException</A></PRE><DL><DD>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><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#OPEN"><CODE>OPEN</CODE></A></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><A HREF="../../../javax/sound/sampled/LineUnavailableException.html"><CODE>LineUnavailableException</CODE></A></code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>stream</CODE> - an audio input stream from which audio data will be read into the clip<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/sound/sampled/LineUnavailableException.html">LineUnavailableException</A></CODE> - if the line cannot be opened due to resource restrictions<DD><CODE><A HREF="../../../java/io/IOException.html">IOException</A></CODE> - if an I/O exception occurs during reading of the stream<DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if the line is already open<DD><CODE><A HREF="../../../java/lang/SecurityException.html">SecurityException</A></CODE> - if the line cannot be opened due to security restrictions<DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/Line.html#close()"><CODE>Line.close()</CODE></A>, <A HREF="../../../javax/sound/sampled/Line.html#isOpen()"><CODE>Line.isOpen()</CODE></A>, <A HREF="../../../javax/sound/sampled/LineListener.html"><CODE>LineListener</CODE></A></DL></DD></DL><HR><A NAME="getFrameLength()"><!-- --></A><H3>getFrameLength</H3><PRE>public int <B>getFrameLength</B>()</PRE><DL><DD>Obtains the media length in sample frames.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the media length, expressed in sample frames, or <code>AudioSystem.NOT_SPECIFIED</code> if the line is not open.<DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/AudioSystem.html#NOT_SPECIFIED"><CODE>AudioSystem.NOT_SPECIFIED</CODE></A></DL></DD></DL><HR><A NAME="getMicrosecondLength()"><!-- --></A><H3>getMicrosecondLength</H3><PRE>public long <B>getMicrosecondLength</B>()</PRE><DL><DD>Obtains the media duration in microseconds<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the media duration, expressed in microseconds, or <code>AudioSystem.NOT_SPECIFIED</code> if the line is not open.<DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/AudioSystem.html#NOT_SPECIFIED"><CODE>AudioSystem.NOT_SPECIFIED</CODE></A></DL></DD></DL><HR><A NAME="setFramePosition(int)"><!-- --></A><H3>setFramePosition</H3><PRE>public void <B>setFramePosition</B>(int frames)</PRE><DL><DD>Sets the media position in sample frames. The position is zero-based; the first frame is frame number zero. When the clip begins playing the next time, it will start by playing the frame at this position. <p> To obtain the current position in sample frames, use the <code><A HREF="../../../javax/sound/sampled/DataLine.html#getFramePosition()"><CODE>getFramePosition</CODE></A></code> method of <code>DataLine</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>frames</CODE> - the desired new media position, expressed in sample frames</DL></DD></DL><HR><A NAME="setMicrosecondPosition(long)"><!-- --></A><H3>setMicrosecondPosition</H3><PRE>public void <B>setMicrosecondPosition</B>(long microseconds)</PRE><DL><DD>Sets the media position in microseconds. When the clip begins playing the next time, it will start at this position. The level of precision is not guaranteed. For example, an implementation might calculate the microsecond position from the current frame position and the audio sample frame rate. The precision in microseconds would then be limited to the number of microseconds per sample frame. <p> To obtain the current position in microseconds, use the <code><A HREF="../../../javax/sound/sampled/DataLine.html#getMicrosecondPosition()"><CODE>getMicrosecondPosition</CODE></A></code> method of <code>DataLine</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>microseconds</CODE> - the desired new media position, expressed in microseconds</DL></DD></DL><HR><A NAME="setLoopPoints(int, int)"><!-- --></A><H3>setLoopPoints</H3><PRE>public void <B>setLoopPoints</B>(int start, int end)</PRE><DL><DD>Sets the first and last sample frames that will be played in the loop. The ending point must be greater than or equal to the starting point, and both must fall within the the size of the loaded media. A value of 0 for the starting point means the beginning of the loaded media. Similarly, a value of -1 for the ending point indicates the last frame of the media.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>start</CODE> - the loop's starting position, in sample frames (zero-based)<DD><CODE>end</CODE> - the loop's ending position, in sample frames (zero-based), or -1 to indicate the final frame<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - 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 point</DL></DD></DL><HR><A NAME="loop(int)"><!-- --></A><H3>loop</H3><PRE>public void <B>loop</B>(int count)</PRE><DL><DD>Starts looping playback from the current position. Playback will continue to the loop's end point, then loop back to the loop start point <code>count</code> times, and finally continue playback to the end of the clip. <p> 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. <p> A <code>count</code> 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. <p> 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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>count</CODE> - the number of times playback should loop back from the loop's end position to the loop's start position, or <code><A HREF="../../../javax/sound/sampled/Clip.html#LOOP_CONTINUOUSLY"><CODE>LOOP_CONTINUOUSLY</CODE></A></code> to indicate that looping should continue until interrupted</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Clip.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../../javax/sound/sampled/DataLine.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Clip.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -