📄 targetdataline.html
字号:
<!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ 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, int)"><!-- --></A><H3>open</H3><PRE>public void <B>open</B>(<A HREF="../../../javax/sound/sampled/AudioFormat.html">AudioFormat</A> format, int bufferSize) throws <A HREF="../../../javax/sound/sampled/LineUnavailableException.html">LineUnavailableException</A></PRE><DL><DD>Opens the line with the specified format and requested buffer size, causing the line to acquire any required system resources and become operational. <p> The buffer size is specified in bytes, but must represent an integral number of sample frames. Invoking this method with a requested buffer size that does not meet this requirement may result in an IllegalArgumentException. The actual buffer size for the open line may differ from the requested buffer size. The value actually set may be queried by subsequently calling <code><A HREF="../../../javax/sound/sampled/DataLine.html#getBufferSize()"><CODE>DataLine.getBufferSize()</CODE></A></code> <p> 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 that is already open is illegal and may result in an <code>IllegalStateException</code>. <p> Some lines, once closed, cannot be reopened. Attempts to reopen such a line will always result in a <code>LineUnavailableException</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>format</CODE> - the desired audio format<DD><CODE>bufferSize</CODE> - the desired buffer size, in bytes.<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/TargetDataLine.html#open(javax.sound.sampled.AudioFormat)"><CODE>open(AudioFormat)</CODE></A>, <A HREF="../../../javax/sound/sampled/Line.html#open()"><CODE>Line.open()</CODE></A>, <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/LineEvent.html"><CODE>LineEvent</CODE></A></DL></DD></DL><HR><A NAME="open(javax.sound.sampled.AudioFormat)"><!-- --></A><H3>open</H3><PRE>public void <B>open</B>(<A HREF="../../../javax/sound/sampled/AudioFormat.html">AudioFormat</A> format) throws <A HREF="../../../javax/sound/sampled/LineUnavailableException.html">LineUnavailableException</A></PRE><DL><DD>Opens the line with the specified format, causing the line to acquire any required system resources and become operational. <p> The implementation chooses a buffer size, which is measured in bytes but which encompasses an integral number of sample frames. The buffer size that the system has chosen may be queried by subsequently calling <code><A HREF="../../../javax/sound/sampled/DataLine.html#getBufferSize()"><CODE>DataLine.getBufferSize()</CODE></A></code> <p> 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 that is already open is illegal and may result in an <code>IllegalStateException</code>. <p> Some lines, once closed, cannot be reopened. Attempts to reopen such a line will always result in a <code>LineUnavailableException</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>format</CODE> - the desired audio format<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/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/TargetDataLine.html#open(javax.sound.sampled.AudioFormat, int)"><CODE>open(AudioFormat, int)</CODE></A>, <A HREF="../../../javax/sound/sampled/Line.html#open()"><CODE>Line.open()</CODE></A>, <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/LineEvent.html"><CODE>LineEvent</CODE></A></DL></DD></DL><HR><A NAME="read(byte[], int, int)"><!-- --></A><H3>read</H3><PRE>public int <B>read</B>(byte[] b, int off, int len)</PRE><DL><DD>Reads audio data from the data line's input buffer. The requested number of bytes is read into the specified array, starting at the specified offset into the array in bytes. This method blocks until the requested amount of data has been read. However, if the data line is closed, stopped, drained, or flushed before the requested amount has been read, the method no longer blocks, but returns the number of bytes read thus far. <p> The number of bytes that can be read without blocking can be ascertained using the <code><A HREF="../../../javax/sound/sampled/DataLine.html#available()"><CODE>available</CODE></A></code> method of the <code>DataLine</code> interface. (While it is guaranteed that this number of bytes can be read without blocking, there is no guarantee that attempts to read additional data will block.) <p> The number of bytes to be read must represent an integral number of sample frames, such that: <br> <center><code>[ bytes read ] % [frame size in bytes ] == 0</code></center> <br> The return value will always meet this requirement. A request to read a number of bytes representing a non-integral number of sample frames cannot be fulfilled and may result in an IllegalArgumentException.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - a byte array that will contain the requested input data when this method returns<DD><CODE>off</CODE> - the offset from the beginning of the array, in bytes<DD><CODE>len</CODE> - the requested number of bytes to read<DT><B>Returns:</B><DD>the number of bytes actually read<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the requested number of bytes does not represent an integral number of sample frames.<DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/SourceDataLine.html#write(byte[], int, int)"><CODE>SourceDataLine.write(byte[], int, int)</CODE></A>, <A HREF="../../../javax/sound/sampled/DataLine.html#available()"><CODE>DataLine.available()</CODE></A></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/TargetDataLine.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"> <A HREF="../../../javax/sound/sampled/SourceDataLine.html"><B>PREV CLASS</B></A> NEXT CLASS</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="TargetDataLine.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | 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 + -