📄 player.html
字号:
<p> When a <code>Controller</code> is added to a <code>Player</code>, the <code>Player</code> does not transition the added <code>Controller</code> to new state, nor does the <code>Player</code> transition itself forward. The <code>Player</code> either transitions back to the <i>realized</i> state if the added <code>Controller</code> is <i>realized</i> or <i>prefetching</i> or it stays in the <i>prefetched</i> state if the both the <code>Player</code> and the added <code>Controller</code> are in the <i>prefetched</i> state. If the <code>Player</code> makes a state transition as a result of adding a <code>Controller</code> the <code>Player</code> posts a <code>TransitionEvent</code>. <h3>Removing a Controller</h3> To stop a <code>Player</code> from managing another <code>Controller</code>, call <code>removeController</code>. The managing <code>Player</code> must be <i>Stopped</i> before <code>removeController</code> can be called. A <code>ClockStartedError</code> is thrown if <code>removeController</code> is called on a <i>Started</i> <code>Player</code>. <p> When a <code>Controller</code> is removed from a <code>Player's</code> control, the <code>Player</code>: <ul> <li> Resets the <code>Controller's</code> <code>TimeBase</code> to its default. <li> Recalculates its duration and posts a <code>DurationUpdateEvent</code> if the <code>Player's</code> duration is different without the <CODE>Controller</CODE> added. <li> Recalculates its start latency. </ul> <h3>Setting the Media Time and Rate of a Managing Player</h3> When you call <code>setMediaTime</code> on a <code>Player</code> that's managing other <code>Controllers</code>, its actions differ depending on whether or not the <code>Player</code> is <I>Started</I>. If the <code>Player</code> is not <i>Started</i>, it simply invokes <code>setMediaTime</code> on all of the <code>Controllers</code> it's managing. <p> If the <code>Player</code> is <i>Started</i>, it posts a <code>RestartingEvent</code> and performs the following tasks for each managed <code>Controller</code>: <ul> <li>Invokes <code>stop</code> on the <code>Controller</code>. <li>Invokes <code>setMediaTime</code> on the <code>Controller</code>. <li>Invokes <code>prefetch</code> on the <code>Controller</code>. <li>Waits for a <code>PrefetchCompleteEvent</code> from the <code>Controller</code>. <li>Invokes <code>syncStart</code> on the <code>Controller</code> </ul> <p> The same is true when <code>setRate</code> is called on a managing <code>Player</code>. The <code>Player</code> attempts to set the specified rate on all managed <code>Controllers</code>, stopping and restarting the <code>Controllers</code> if necessary. If some of the <code>Controllers</code> do not support the requested rate, the <code>Player</code> returns the rate that was actually set. All <code>Controllers</code> are guaranteed to have been successfully set to the rate returned. <h3>Starting a Managing Player</h3> When you call <code>start</code> on a managing <code>Player</code>, all of the <code>Controllers</code> managed by the <code>Player</code> are transitioned to the <i>Prefetched</i> state. When the <code>Controllers</code> are <i>Prefetched</i>, the managing <code>Player</code> calls <code>syncStart</code> with a time consistent with the latencies of each of the managed <code>Controllers</code>. <h3>Calling realize, prefetch, stop, or deallocate on a Managing Player</h3> When you call <code>realize</code>, <code>prefetch</code>, <code>stop</code>, or <code>deallocate</code> on a managing <code>Player</code>, the <code>Player</code> calls that method on all of the <code>Controllers</code> that it is managing. The <code>Player</code> moves from one state to the next when all of its <code>Controllers</code> have reached that state. For example, a <code>Player</code> in the <i>Prefetching</i> state does not transition into the <i>Prefetched</i> state until all of its managed <code>Controllers</code> are <i>Prefetched</i>. The <code>Player</code> posts <code>TransitionEvents</code> normally as it changes state. <p> <h3>Calling syncStart or setStopTime on a Managing Player</h3> When you call <code>syncStart</code> or <code>setStopTime</code> on a managing <code>Player</code>, the <code>Player</code> calls that method on all of the <code>Controllers</code> that it is managing. (The <code>Player</code> must be in the correct state or an error is thrown. For example, the <code>Player</code> must be <I>Prefetched</I> before you can call <code>syncStart</code>.) <h3>Setting the Time Base of a Managing Player</h3> When <code>setTimeBase</code> is called on a managing <code>Player</code>, the <code>Player</code> calls <code>setTimeBase</code> on all of the <code>Controllers</code> it's managing. If <code>setTimeBase</code> fails on any of the <code>Controllers</code>, an <code>IncompatibleTimeBaseException</code> is thrown and the <code>TimeBase</code> last used is restored for all of the <code>Controllers</code>. <h3>Getting the Duration of a Managing Player</h3> Calling <code>getDuration</code> on a managing <code>Player</code> returns the maximum duration of all of the added <code>Controllers</code> and the managing <code>Player</code>. If the <CODE>Player</CODE> or any <CODE>Controller</CODE> has not resolved its duration, <code>getDuration</code> returns <code>Duration.DURATION_UNKNOWN</code>. <h3> Closing a Managing Player</h3> When <code>close</code> is called on a managing <code>Player</code> all managed <code>Controllers</code> are closed as well. <a name="events"><h3>Events</h3></a> Most events posted by a managed <code>Controller</code> are filtered by the managing <code>Player</code>. Certain events are sent directly from the <code>Controller</code> through the <code>Player</code> and to the listeners registered with the <code>Player</code>. <p> To handle the events that a managed <code>Controller</code> can generate, the <code>Player</code> registers a listener with the <code>Controller</code> when it is added. Other listeners that are registered with the <code>Controller</code> must be careful not to invoke methods on the <code>Controller</code> while it is being managed by the <code>Player</code>. Calling a control method on a managed <code>Controller</code> directly will produce unpredictable results. <p> When a <CODE>Controller</CODE> is removed from the <code>Player's</code> list of managed <code>Controllers</code>, the <code>Player</code> removes itself from the <code>Controller's</code> listener list. <h4>Transition Events</h4> A managing <code>Player</code> posts <code>TransitionEvents</code> normally as it moves between states, but the managed <code>Controllers</code> affect when the <code>Player</code> changes state. In general, a <code>Player</code> does not post a transition event until all of its managed <code>Controllers</code> have posted the event. <h4>Status Change Events</h4> The managing <code>Player</code> collects the <code>RateChangeEvents</code>, <code>StopTimeChangeEvents</code>, and <code>MediaTimeSetEvents</code> posted by its managed <code>Controllers</code> and posts a single event for the group. <h4>DurationUpdateEvent</h4> A <code>Player</code> posts a <code>DurationUpdateEvent</code> when it determines its duration or its duration changes. A managing <code>Player's</code> duration might change if a managed <code>Controller</code> updates or discovers its duration. In general, if a managed <code>Controller</code> posts a <code>DurationUpdateEvent</code> and the new duration changes the managing <code>Player's</code> duration, the <code>Player</code> posts a <code>DurationUpdateEvent</code> <h4>CachingControlEvent</h4> A managing <CODE>Player</CODE> reposts <CODE>CachingControlEvents</CODE> received from a <CODE>Players</CODE> that it manages, but otherwise ignores the events. <h4>ControllerErrorEvents</h4> A managing <CODE>Player</CODE> immediately reposts any <CODE>ControllerErrorEvent</CODE> received from a <CODE>Controller</CODE> that it is managing. After a <CODE>ControllerErrorEvent</CODE> has been received from a managed <CODE>Controller</CODE>, a managing <CODE>Player</CODE> no longer invokes any methods on the managed <CODE>Controller</CODE>; the managed <CODE>Controller</CODE> is ignored from that point on.<P><DL><DT><B>See Also: </B><DD><A HREF="../../javax/media/Manager.html"><CODE>Manager</CODE></A>, <A HREF="../../javax/media/GainControl.html"><CODE>GainControl</CODE></A>, <A HREF="../../javax/media/Clock.html"><CODE>Clock</CODE></A>, <A HREF="../../javax/media/TransitionEvent.html"><CODE>TransitionEvent</CODE></A>, <A HREF="../../javax/media/RestartingEvent.html"><CODE>RestartingEvent</CODE></A>, <A HREF="../../javax/media/DurationUpdateEvent.html"><CODE>DurationUpdateEvent</CODE></A>, <CODE>Component</CODE></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="fields_inherited_from_class_javax.media.Controller"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from interface javax.media.<A HREF="../../javax/media/Controller.html">Controller</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../javax/media/Controller.html#LATENCY_UNKNOWN">LATENCY_UNKNOWN</A>, <A HREF="../../javax/media/Controller.html#Prefetched">Prefetched</A>, <A HREF="../../javax/media/Controller.html#Prefetching">Prefetching</A>, <A HREF="../../javax/media/Controller.html#Realized">Realized</A>, <A HREF="../../javax/media/Controller.html#Realizing">Realizing</A>, <A HREF="../../javax/media/Controller.html#Started">Started</A>, <A HREF="../../javax/media/Controller.html#Unrealized">Unrealized</A></CODE></TD></TR></TABLE> <A NAME="fields_inherited_from_class_javax.media.Clock"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from interface javax.media.<A HREF="../../javax/media/Clock.html">Clock</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../javax/media/Clock.html#RESET">RESET</A></CODE></TD></TR></TABLE> <A NAME="fields_inherited_from_class_javax.media.Duration"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from interface javax.media.<A HREF="../../javax/media/Duration.html">Duration</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../javax/media/Duration.html#DURATION_UNBOUNDED">DURATION_UNBOUNDED</A>, <A HREF="../../javax/media/Duration.html#DURATION_UNKNOWN">DURATION_UNKNOWN</A></CODE></TD></TR></TABLE> <!-- ======== 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> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/media/Player.html#addController(javax.media.Controller)">addController</A></B>(<A HREF="../../javax/media/Controller.html">Controller</A> newController)</CODE><BR> Tells the <CODE>Player</CODE> to assume control of another <code>Controller</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.awt.Component</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/media/Player.html#getControlPanelComponent()">getControlPanelComponent</A></B>()</CODE><BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -