📄 jmfpresenting.html
字号:
</p>
<p>
<a name="94621"> </a><font face="Palatino, Times New Roman, Times, serif">This mechanism is implemented through the <code>addController</code> and <code>removeController</code> methods. When you call <code>addController</code> on a <code>Player</code>, the <code>Controller</code> you specify is added to the list of <code>Controllers</code> managed by the <code>Player</code>. Conversely, when you call <code>removeController</code>, the specified <code>Controller</code> is removed from the list of managed <code>Controllers</code>. </font>
</p>
<p>
<a name="94624"> </a><font face="Palatino, Times New Roman, Times, serif">Typically, when you need to synchronize <code>Players </code>or other <code>Controllers</code>, you should use this <code>addController</code> mechanism. It is simpler, faster, and less error-prone than attempting to manage synchronized <code>Players</code> individually.</font>
</p>
<p>
<a name="94625"> </a><font face="Palatino, Times New Roman, Times, serif">When a <code>Player</code> assumes control of a <code>Controller</code>:</font>
</p>
<ul>
<li><a name="94626"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>Controller</code> assumes the <code>Player </code>object's time base.</font>
<li><a name="94627"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>Player </code>object's<code> </code>duration becomes the longer of the <code>Controller </code>object's duration and its own. If multiple <code>Controllers</code> are placed under a <code>Player </code>object's control, the <code>Player </code>object's duration is set to longest duration.</font>
<li><a name="101847"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>Player </code>object's start latency becomes the longer of the <code>Controller </code>object's start latency and its own. If multiple <code>Controllers</code> are placed under a <code>Player </code>object's control, the <code>Player </code>object's start latency is set to the longest latency. </font>
</ul>
<p>
<a name="94629"> </a><font face="Palatino, Times New Roman, Times, serif">A managing <code>Player</code> only posts completion events for asynchronous methods after each of its managed <code>Controllers</code> have posted the event. The managing <code>Player </code>reposts other events generated by the <code>Controllers</code> as appropriate. </font>
</p>
<h5>
<a name="93874"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Adding a Controller</font></i>
</h5>
<p>
<a name="94642"> </a><font face="Palatino, Times New Roman, Times, serif">You use the <code>addController</code> method to add a <code>Controller</code> to the list of <code>Controllers</code> managed by a particular <code>Player</code>. To be added, a <code>Controller</code> must be in the <em>Realized</em> state; otherwise, a <code>NotRealizedError</code> is thrown. Two <code>Players </code>cannot be placed under control of each other. For example, if <code>player1</code> is placed under the control of <code>player2</code>, <code>player2</code> cannot be placed under the control of <code>player1 </code>without first removing<code> player1 </code>from<code> player2's </code>control.</font>
</p>
<p>
<a name="94644"> </a><font face="Palatino, Times New Roman, Times, serif">Once a <code>Controller</code> has been added to a <code>Player</code>, do not call methods directly on the managed <code>Controller</code>. To control a managed <code>Controller</code>, you interact with the managing <code>Player</code>. </font>
</p>
<p>
<a name="94646"> </a><font face="Palatino, Times New Roman, Times, serif">To have <code>player2</code> assume control of <code>player1</code>, call:</font>
</p>
<pre>
<a name="94647"> </a><code>player2.addController(player1</code>);
</pre>
<h5>
<a name="93875"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Controlling Managed Controllers</font></i>
</h5>
<p>
<a name="94654"> </a><font face="Palatino, Times New Roman, Times, serif">To control the operation of a group of <code>Controllers</code> managed by a particular <code>Player</code>, you interact directly with the managing <code>Player</code>. </font>
</p>
<p>
<a name="94655"> </a><font face="Palatino, Times New Roman, Times, serif">For example, to prepare all of the managed <code>Controllers</code> to start, call <code>prefetch</code> on the managing <code>Player</code>. Similarly, when you want to start them, call <code>start</code> on the managing <code>Player</code>. The managing <code>Player</code> makes sure that all of the <code>Controllers</code> are <em>Prefetched</em>, determines the maximum start latency among the <code>Controllers</code>, and calls <code>syncStart</code> to start them, specifying a time that takes the maximum start latency into account.</font>
</p>
<p>
<a name="94657"> </a><font face="Palatino, Times New Roman, Times, serif">When you call a <code>Controller</code> method on the managing <code>Player</code>, the <code>Player</code> propagates the method call to the managed <code>Controllers</code> as appropriate. Before calling a <code>Controller</code> method on a managed <code>Controller</code>, the <code>Player</code> ensures that the <code>Controller</code> is in the proper state. The following table describes what happens to the managed <code>Controllers</code> when you call control methods on the managing <code>Player</code>.</font>
</p>
<a name="99659"> </a><font size="1" face="Palatino, Times New Roman, Times, serif">
<table border="1" bordercolorlight="#FFFFFF" bordercolordark="#000000"
cellpadding="5" cellspacing="0">
<caption><b><i><font face="Palatino, Times New Roman, Times, serif"></font></i></b></caption>
<tr bgcolor="#CCCCCC"><div align="center">
<th><font face="Palatino, Times New Roman, Times, serif" color="#003366"><a name="98182"> </a>Function</font></th>
<th><font face="Palatino, Times New Roman, Times, serif" color="#003366"><a name="98184"> </a>Stopped Player</font></th>
<th><font face="Palatino, Times New Roman, Times, serif" color="#003366"><a name="98186"> </a>Started Player</font></th>
</div></tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94667"> </a><code>setMediaTime</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94669"> </a>Invokes <code>setMediaTime</code> on all managed <code>Controllers</code>.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94671"> </a>Stops all managed <code>Controllers</code>, invokes <code>setMediaTime</code>, and restarts <code>Controllers</code>.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94673"> </a><code>setRate</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94675"> </a>Invokes <code>setRate</code> on all managed <code>Controllers</code>. Returns the actual rate that was supported by all <code>Controllers</code> and set.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94677"> </a>Stops all managed <code>Controllers</code>, invokes <code>setRate</code>, and restarts <code>Controllers</code>. Returns the actual rate that was supported by all <code>Controllers</code> and set.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94679"> </a><code>start</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94681"> </a>Ensures all managed <code>Controllers</code> are <em>Prefetched</em> and invokes <code>syncStart</code> on each of them, taking into account their start latencies.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94683"> </a>Depends on the <code>Player</code> implementation. <code>Player</code> might immediately post a <code>StartEvent</code>.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94685"> </a><code>realize</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94687"> </a>The managing <code>Player</code> immediately posts a <code>RealizeCompleteEvent</code>. To be added, a <code>Controller</code> must already be realized.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94689"> </a>The managing <code>Player</code> immediately posts a <code>RealizeCompleteEvent</code>. To be added, a <code>Controller</code> must already be realized.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94691"> </a><code>prefetch</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94693"> </a>Invokes <code>prefetch</code> on all managed <code>Controllers</code>. </font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94695"> </a>The managing <code>Player</code> immediately posts a <code>PrefetchCompleteEvent</code>, indicating that all managed <code>Controllers</code> are <em>Prefetched</em>.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94697"> </a><code>stop</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94699"> </a>No effect.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94701"> </a>Invokes <code>stop</code> on all managed <code>Controllers</code>.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94703"> </a><code>deallocate</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94705"> </a>Invokes <code>deallocate</code> on all managed <code>Controllers</code>.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94707"> </a>It is illegal to call <code>deallocate</code> on a <em>Started</em> <code>Player</code>.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94709"> </a><code>setStopTime</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94711"> </a>Invokes <code>setStopTime</code> on all managed <code>Controllers</code>. (<code>Player</code> must be <em>Realized</em>.)</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94713"> </a>Invokes <code>setStopTime</code> on all managed <code>Controllers</code>. (Can only be set once on a <em>Started</em> <code>Player</code>.)</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94715"> </a><code>syncStart</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94717"> </a>Invokes <code>syncStart</code> on all managed <code>Controllers</code>. </font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94719"> </a>It is illegal to call <code>syncStart</code> on a <em>Started</em> <code>Player</code>.</font></td>
</tr>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94721"> </a><code>close</code></font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94723"> </a>Invokes <code>close</code> on all managed <code>Controllers</code>.</font></td>
<td><font face="Palatino, Times New Roman, Times, serif"><a name="94725"> </a>It is illegal to call <code>close</code> on a <em>Started</em> <code>Player</code>.</font></td>
</tr>
</table>
<br></font>
<a name="93876"> </a><font size="2" face="Palatino, Times New Roman, Times, serif">Table 3-1: Calling control methods on a managing player.<br></font>
<h5>
<a name="100015"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Removing a Controller</font></i>
</h5>
<p>
<a name="94749"> </a><font face="Palatino, Times New Roman, Times, serif">You use the <code>removeController</code> method to remove a <code>Controller</code> from the list of controllers managed by a particular <code>Player</code>. </font>
</p>
<p>
<a name="94751"> </a><font face="Palatino, Times New Roman, Times, serif">To have <code>player2</code> release control of <code>player1</code>, call:</font>
</p>
<pre>
<a name="94752"> </a><code>player2.removeController(player1</code>);
</pre>
<h4>
<a name="93877"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Synchronizing Players Directly</font>
</h4>
<p>
<a name="94583"> </a><font face="Palatino, Times New Roman, Times, serif">In a few situations, you might want to manage the synchronization of multiple <code>Player</code> objects yourself so that you can control the rates or media times independently. If you do this, you must:</font>
</p>
<ol type="1">
<li value="1"><a name="94585"> </a><font face="Palatino, Times New Roman, Times, serif">Register as a listener for each synchronized <code>Player</code>.</font>
<li value="2"><a name="94586"> </a><font face="Palatino, Times New Roman, Times, serif">Determine which <code>Player </code>object's time base is going to be used to drive the other <code>Player </code>objects and set the time base for the synchronized <code>Player </code>objects. Not all <code>Player objects </code>can assume a new time base. For example, if one of the <code>Player </code>objects you want to synchronize has a push data-source, that <code>Player </code>object's<code> </code>time base must be used to drive the other <code>Player objects</code>. </font>
<li value="3"><a name="94587"> </a><font face="Palatino, Times New Roman, Times, serif">Set the rate for all of the <code>Players</code>. If a <code>Player</code> cannot support the rate you specify, it returns the rate that was used. (There is no mechanism for querying the rates that a <code>Player</code> supports.)</font>
<li value="4"><a name="94588"> </a><font face="Palatino, Times New Roman, Times, serif">Synchronize the states of all of the <code>Player</code> objects. (For example, stop all of the players.)</font>
<li value="5"><a name="94589"> </a><font face="Palatino, Times New Roman, Times, serif">Synchronize the operation of the <code>Player</code> objects:</font>
<ul>
<li><a name="94590"> </a><font face="Palatino, Times New Roman, Times, serif">Set the media time for each <code>Player</code>.</font>
<li><a name="94591"> </a><font face="Palatino, Times New Roman, Times, serif">Prefetch each <code>Player</code>.</font>
<li><a name="94592"> </a><font face="Palatino, Times New Roman, Times, serif">Determine the maximum start latency among the synchronized <code>Player </code>objects. </font>
<li><a name="94594"> </a><font face="Palatino, Times New Roman, Times, serif">Start the <code>Player</code> objects by calling <code>syncStart</code> with a time that takes into account the maximum latency. </font>
</ul>
</ol>
<p>
<a name="94595"> </a><font face="Palatino, Times New Roman, Times, serif">You must listen for transition events for all of the <code>Player objects</code> and keep track of which ones have posted events. For example, when you prefetch the <code>Player </code>objects, you need to keep track of which ones have posted <code>PrefetchComplete</code> events so that you can be sure all of them are <em>Prefetched</em> before calling <code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -