📄 dataline.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:37:54 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface DataLine</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_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/DataLine.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/Clip.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/sound/sampled/Line.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="DataLine.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#inner_class_summary">INNER</A> | 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><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.sound.sampled</FONT><BR>Interface DataLine</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../../javax/sound/sampled/Line.html">Line</A></DD></DL><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../../javax/sound/sampled/Clip.html">Clip</A>, <A HREF="../../../javax/sound/sampled/SourceDataLine.html">SourceDataLine</A>, <A HREF="../../../javax/sound/sampled/TargetDataLine.html">TargetDataLine</A></DD></DL><HR><DL><DT>public interface <B>DataLine</B><DT>extends <A HREF="../../../javax/sound/sampled/Line.html">Line</A></DL><P><code>DataLine</code> adds media-related functionality to its superinterface, <code><A HREF="../../../javax/sound/sampled/Line.html"><CODE>Line</CODE></A></code>. This functionality includes transport-control methods that start, stop, drain, and flush the audio data that passes through the line. A data line can also report the current position, volume, and audio format of the media. Data lines are used for output of audio by means of the subinterfaces <code><A HREF="../../../javax/sound/sampled/SourceDataLine.html"><CODE>SourceDataLine</CODE></A></code> or <code><A HREF="../../../javax/sound/sampled/Clip.html"><CODE>Clip</CODE></A></code>, which allow an application program to write data. Similarly, audio input is handled by the subinterface <code><A HREF="../../../javax/sound/sampled/TargetDataLine.html"><CODE>TargetDataLine</CODE></A></code>, which allows data to be read. <p> A data line has an internal buffer in which the incoming or outgoing audio data is queued. The <code><A HREF="../../../javax/sound/sampled/DataLine.html#drain()"><CODE>drain()</CODE></A></code> method blocks until this internal buffer becomes empty, usually because all queued data has been processed. The <code><A HREF="../../../javax/sound/sampled/DataLine.html#flush()"><CODE>flush()</CODE></A></code> method discards any available queued data from the internal buffer. <p> A data line produces <code><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#START"><CODE>START</CODE></A></code> and <code><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#STOP"><CODE>STOP</CODE></A></code> events whenever it begins or ceases active presentation or capture of data. These events can be generated in response to specific requests, or as a result of less direct state changes. For example, if <code><A HREF="../../../javax/sound/sampled/DataLine.html#start()"><CODE>start()</CODE></A></code> is called on an inactive data line, and data is available for capture or playback, a <code>START</code> event will be generated shortly, when data playback or capture actually begins. Or, if the flow of data to an active data line is constricted so that a gap occurs in the presentation of data, a <code>STOP</code> event is generated. <p> Mixers often support synchronized control of multiple data lines. Synchronization can be established through the Mixer interface's <code><A HREF="../../../javax/sound/sampled/Mixer.html#synchronize(javax.sound.sampled.Line[], boolean)"><CODE>synchronize</CODE></A></code> method. See the description of the <code><A HREF="../../../javax/sound/sampled/Mixer.html"><CODE>Mixer</CODE></A></code> interface for a more complete description.<P><DL><DT><B>Since: </B><DD>1.3</DD><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/LineEvent.html"><CODE>LineEvent</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_class_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Inner Class Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.Info.html">DataLine.Info</A></B></CODE><BR> Besides the class information inherited from its superclass, <code>DataLine.Info</code> provides additional information specific to data lines.</TD></TR></TABLE> <A NAME="inner_classes_inherited_from_class_javax.sound.sampled.Line"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class javax.sound.sampled.<A HREF="../../../javax/sound/sampled/Line.html">Line</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../javax/sound/sampled/Line.Info.html">Line.Info</A></CODE></TD></TR></TABLE> <!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#available()">available</A></B>()</CODE><BR> Obtains the number of bytes of data currently available to the application for processing in the data line's internal buffer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#drain()">drain</A></B>()</CODE><BR> Drains queued data from the line by continuing data I/O until the data line's internal buffer has been emptied.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#flush()">flush</A></B>()</CODE><BR> Flushes queued data from the line.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#getBufferSize()">getBufferSize</A></B>()</CODE><BR> Obtains the maximum number of bytes of data that will fit in the data line's internal buffer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/sound/sampled/AudioFormat.html">AudioFormat</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#getFormat()">getFormat</A></B>()</CODE><BR> Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#getFramePosition()">getFramePosition</A></B>()</CODE><BR> Obtains the current position in the audio data, in sample frames.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> float</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#getLevel()">getLevel</A></B>()</CODE><BR> Obtains the current volume level for the line.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> long</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#getMicrosecondPosition()">getMicrosecondPosition</A></B>()</CODE><BR> Obtains the current position in the audio data, in microseconds.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#isActive()">isActive</A></B>()</CODE><BR> Indicates whether the line is engaging in active I/O (such as playback or capture).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#isRunning()">isRunning</A></B>()</CODE><BR> Indicates whether the line is running.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#start()">start</A></B>()</CODE><BR> Allows a line to engage in data I/O.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/DataLine.html#stop()">stop</A></B>()</CODE><BR> Stops the line.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_javax.sound.sampled.Line"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface javax.sound.sampled.<A HREF="../../../javax/sound/sampled/Line.html">Line</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../javax/sound/sampled/Line.html#addLineListener(javax.sound.sampled.LineListener)">addLineListener</A>, <A HREF="../../../javax/sound/sampled/Line.html#close()">close</A>, <A HREF="../../../javax/sound/sampled/Line.html#getControl(javax.sound.sampled.Control.Type)">getControl</A>, <A HREF="../../../javax/sound/sampled/Line.html#getControls()">getControls</A>, <A HREF="../../../javax/sound/sampled/Line.html#getLineInfo()">getLineInfo</A>, <A HREF="../../../javax/sound/sampled/Line.html#isControlSupported(javax.sound.sampled.Control.Type)">isControlSupported</A>, <A HREF="../../../javax/sound/sampled/Line.html#isOpen()">isOpen</A>, <A HREF="../../../javax/sound/sampled/Line.html#open()">open</A>, <A HREF="../../../javax/sound/sampled/Line.html#removeLineListener(javax.sound.sampled.LineListener)">removeLineListener</A></CODE></TD></TR></TABLE> <P><!-- ============ 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="drain()"><!-- --></A><H3>drain</H3><PRE>public void <B>drain</B>()</PRE><DL><DD>Drains queued data from the line by continuing data I/O until the data line's internal buffer has been emptied.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -