📄 player.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 Sat May 20 18:57:44 PDT 2000 --><TITLE>: Interface Player</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 ID="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="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="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../javax/media/Owned.html"><B>PREV CLASS</B></A> <A HREF="../../javax/media/PlugIn.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="Player.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><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.media</FONT><BR>Interface Player</H2><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../javax/media/Processor.html">Processor</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../javax/media/bean/playerbean/MediaPlayer.html">MediaPlayer</A></DD></DL><HR><DL><DT>public interface <B>Player</B><DT>extends <A HREF="../../javax/media/MediaHandler.html">MediaHandler</A>, <A HREF="../../javax/media/Controller.html">Controller</A></DL><P><code>Player</code> is a <code>MediaHandler</code> for rendering and controlling time based media data. <code>Player</code> extends the <code>Controller</code> interface. <code>Player</code> provides methods for obtaining AWT components, media processing controls, and a way to manage other <code>Controllers</code>. <h2>How a Player Differs from a Controller</h2> <code>Player</code> relaxes some restrictions that a <code>Controller</code> imposes on what methods can be called on a <i>Started</i> <code>Controller</code>. It also provides a way to manage groups of <CODE>Controllers</CODE>. <h3>Methods Restricted to <i>Stopped</i> Players</h3> The following methods cannot be invoked on a <i>Started</i> <CODE>Player</CODE>. If they are, <code>ClockStartedError</code> is thrown. <ul> <li> <code>setTimeBase</code> <li> <code>syncStart</code> <li> <code>deallocate</code> <li> <code>addController</code> <li> <code>removeController</code> </ul> <p> <h3>Methods Allowed on <i>Started</i> Players</h3> Unlike a <code>Controller</code>, the following methods are <i>legal</i> on a <code>Player</code> in the <i>Started</i> state: <ul> <li> <code>setMediaTime</code> <li> <code>setRate</code> </ul> Invoking these methods on a <i>Started</i> <code>Player</code> might initiate significant and time-consuming processing, depending on the location and type of media being processed. These methods might also cause the state of the <code>Player</code> to change. If this happens, the appropriate <code>TransitionEvents</code> are posted by the <code>Player</code> when its state changes. <p> For example, a <code>Player</code> might have to enter the <i>Prefetching</i> state to process a <code>setMediaTime</code> invocation. In this case, the <code>Player</code> posts a <code>RestartingEvent</code>, a <code>PrefetchCompleteEvent</code>, and a <code>StartEvent</code> as it moves from the <i>Started</i> state to <i>Prefetching</i>, back to <i>Prefetched</i>, and finally back to the <i>Started</i> state. <h3>Methods that are Illegal on <i>Unrealized</i> Players</h3> As with <code>Controller</code>, it is illegal to call the following methods on an <i>Unrealized</i> <code>Player</code>: <ul> <li> <code>getTimeBase</code> <li> <code>setTimeBase</code> <li> <code>setMediaTime</code> <li> <code>setRate</code> <li> <code>setStopTime</code> <li> <code>getStartLatency</code> </ul> <p> It is also illegal to call the following <code>Player</code> methods on an <i>Unrealized</i> <code>Player</code>: <ul> <li> <code>getVisualComponent</code> <li> <code>getControlPanelComponent</code> <li> <code>getGainControl</code> <li> <code>addController</code> <li> <code>removeController</code> </ul> <p> The <code>Player</code> throws a <code>NotRealizedError</code> if any of these methods are called while the <code>Player</code> is in the <i>Unrealized</i> state. <h3>Start Method </h3> As a convenience, <code>Player</code> provides a <code>start</code> method that can be invoked before a <code>Player</code> is <i>Prefetched</i>. This method attempts to transition the <code>Player</code> to the <i>Started</i> state from whatever state it's currently in. For example, if the <code>Player</code> is <i>Unrealized</i>, <code>start</code> implicitly calls <code>realize</code>, <code>prefetch</code>, and <code>Clock.syncStart</code>. The appropriate <code>TransitionEvents</code> are posted as the <code>Player</code> moves through each state on its way to <i>Started</i>. <h3>RestartingEvent</h3> If <code>setMediaTime</code> or <code>setRate</code> cause a perceptible delay in the presentation of the media, the <code>Player</code> posts a <code>RestartingEvent</code> and transitions to the <i>Prefetching</i> state. The previous state and target state of a <code>RestartingEvent</code> is always <i>Started</i>. <code>RestartingEvent</code> is a subclass of <code>StopEvent</code>. <h3>DurationUpdateEvent</h3> Because a <code>Player</code> cannot always know the duration of the media it is playing, the <code>Duration</code> interface defines that <code>getDuration</code> returns <code>Duration.DURATION_UNKNOWN</code> until the duration can be determined. A <code>DurationUpdateEvent</code> is generated when the <code>Player</code> can determine its duration or the if its duration changes, which can happen at any time. When the end of the media is reached, the duration should be known. <h2>Managing other Controllers</h2> In some situations, an application might want to use a single <code>Player</code> to control other <code>Players</code> or <code>Controllers</code>. A single controlling <code>Player</code> can be used to invoke <code>start</code>, <code>stop</code>, <code>setMediaTime</code>, and other methods on the entire group. The controlling <code>Player</code> manages all of the state transitions and event posting. <p> It is also possible to construct a simple <code>Controller</code> to update animations, report on media time-line progress, or provide other timing-related functions. Such <code>Controllers</code> can operate in sync with a controlling <code>Player</code>. <h3>Adding a Controller</h3> To have a <CODE>Player</CODE> assume control over a <code>Controller</code>, use the <code>addController</code> method. A <code>Controller</code> can not be added to a <i>Started</i> <code>Player</code>. If <code>addController</code> is called on a <i>Started</i> <code>Player</code>, a <code>ClockStartedError</code> is thrown. An <i>Unrealized</i>  or <code>Started</code>;<code>Controller</code> cannot be added to a <code>Player</code>; a <code>NotRealizedError</code> is thrown if the <code>Controller</code> is <i>Unrealized</i>; a <code>ClockStartedError</code> is thrown if the <code>Controller</code> is <i>Started</i>. <p> Once a <code>Controller</code> has been added, the <code>Player</code>: <ul> <li>Invokes <code>setTimeBase</code> on the <code>Controller</code> with the <code>Player's</code> <code>TimeBase</code>. If this fails, <code>addController</code> throws an <code>IncompatibleTimeBaseException</code>. <li>Synchronizes the <code>Controller</code> with the <code>Player</code> using <code>setMediaTime</code>, <code>setStopTime</code>, and <code>setRate</code>. <li>Takes the added <code>Controller's</code> latency into account when computing the <code>Player's</code> start latency. When <code>getStartLatency</code> is called, the <code>Player</code> returns the greater of: its latency before the <code>Controller</code> was added and the latency of the added <code>Controller</code>. <li>Takes the added <code>Controller's</code> duration into account when computing the <code>Player's</code> duration. When <code>getDuration</code> is called, the <code>Player</code> returns the greater of: its duration before the <code>Controller</code> was added and the duration of the added <code>Controller</code>. If either of these values is DURATION_UNKNOWN, <CODE>getDuration</CODE> returns DURATION_UNKNOWN. If either of these values is DURATION_UNBOUNDED <CODE>getDuration</CODE> returns DURATION_UNBOUNDED. <li> Adds itself as a <code>ControllerListener</code> for the added <code>Controller</code> so that it can manage the events that the <code>Controller</code> generates. (See the <a href="#events">Events</a> section below for more information.) <li>Invokes control methods on the added <code>Controller</code> in response to methods invoked on the <code>Player</code>. The methods that affect managed <code>Controllers</code> are discussed below. </ul> Once a <code>Controller</code> has been added to a <code>Player</code>, methods should only be called on the <code>Controller</code> through the managing <code>Player</code>. It is not defined how the <code>Controller</code> or <code>Player</code> will behave if methods are called directly on an added <code>Controller</code>. You cannot place a controlling <CODE>Player</CODE> under the control of a <CODE>Player</CODE> that it is managing; the resulting behavior is undefined.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -