⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmfpresenting.html

📁 奉献给多媒体java编程者们。JMF2.1.1最新版本的用户指南。JMF是java用于基于实时多媒体的开发工具
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<h5>
  <a name="93861"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Determining the Start Latency</font></i>
</h5>


<p>
  <a name="94409"> </a><font face="Palatino, Times New Roman, Times, serif">To determine how much time is required to start a <code>Player</code>, you can call <code>getStartLatency</code>. For <code>Players</code> that have a variable start latency, the return value of <code>getStartLatency</code> represents the maximum possible start latency. For some media types, <code>getStartLatency</code> might return <code>LATENCY_UNKNOWN</code>. </font>
</p>


<p>
  <a name="94411"> </a><font face="Palatino, Times New Roman, Times, serif">The start-up latency reported by <code>getStartLatency</code> might differ depending on the <code>Player </code>object's<code> </code>current state. For example, after a <code>prefetch</code> operation, the value returned by <code>getStartLatency</code> is typically smaller. A <code>Controller</code> that can be added to a <code>Player</code> will return a useful value once it is <em>Prefetched</em>. (For more information, see <a href="JMFPresenting.html#93873">Using a Player to Synchronize Controllers</a>.)</font>
</p>


<h4>
  <a name="93862"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Starting and Stopping the Presentation</font>
</h4>


<p>
  <a name="94284"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>Clock</code> and <code>Player</code> interfaces define the methods for starting and stopping presentation.</font>
</p>


<h5>
  <a name="94338"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Starting the Presentation</font></i>
</h5>


<p>
  <a name="94289"> </a><font face="Palatino, Times New Roman, Times, serif">You typically start the presentation of media data by calling <code>star</code>t. The <code>start</code> method tells the <code>Player</code> to begin presenting media data as soon as possible. If necessary, <code>start</code> prepares the <code>Player</code> to start by performing the realize and prefetch operations. If <code>start</code> is called on a <em>Started</em> <code>Player</code>, the only effect is that a <code>StartEvent</code> is posted in acknowledgment of the method call.</font>
</p>


<p>
  <a name="94293"> </a><font face="Palatino, Times New Roman, Times, serif">Clock defines a <code>syncStart</code> method that can be used for synchronization. See <a href="JMFPresenting.html#94786">Synchronizing Multiple Media Streams</a> for more information.</font>
</p>


<p>
  <a name="94298"> </a><font face="Palatino, Times New Roman, Times, serif">To start a <code>Player</code> at a specific point in a media stream:</font>
</p>

<ol type="1">
  <li value="1"><a name="94299"> </a><font face="Palatino, Times New Roman, Times, serif">Specify the point in the media stream at which you want to start by calling <code>setMediaTime</code>. </font>
  <li value="2"><a name="94300"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>start</code> on the <code>Player</code>. </font>
</ol>

<h5>
  <a name="94339"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Stopping the Presentation</font></i>
</h5>


<p>
  <a name="94309"> </a><font face="Palatino, Times New Roman, Times, serif">There are four situations in which the presentation will stop:</font>
</p>

<ul>
  <li><a name="94311"> </a><font face="Palatino, Times New Roman, Times, serif">When the <code>stop</code> method is called</font>
  <li><a name="94312"> </a><font face="Palatino, Times New Roman, Times, serif">When the specified stop time is reached</font>
  <li><a name="94313"> </a><font face="Palatino, Times New Roman, Times, serif">When there's no more media data to present</font>
  <li><a name="94314"> </a><font face="Palatino, Times New Roman, Times, serif">When the media data is being received too slowly for acceptable playback</font>
</ul>

<p>
  <a name="94315"> </a><font face="Palatino, Times New Roman, Times, serif">When a <code>Player</code> is stopped, its media time is frozen if the source of the media can be controlled. If the <code>Player</code> is presenting streamed media, it might not be possible to freeze the media time. In this case, only the receipt of the media data is stopped--the data continues to be streamed and the media time continues to advance. </font>
</p>


<p>
  <a name="100485"> </a><font face="Palatino, Times New Roman, Times, serif">When a <em>Stopped</em> <code>Player</code> is restarted, if the media time was frozen, presentation resumes from the stop time. If media time could not be frozen when the <code>Player</code> was stopped, reception of the stream resumes and playback begins with the newly-received data. </font>
</p>


<p>
  <a name="94317"> </a><font face="Palatino, Times New Roman, Times, serif">To stop a <code>Player</code> immediately, you call the <code>stop</code> method. If you call <code>stop</code> on a <em>Stopped</em> <code>Player</code>, the only effect is that a <code>StopByRequestEvent</code> is posted in acknowledgment of the method call.</font>
</p>


<h5>
  <a name="94318"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Stopping the Presentation at a Specified Time</font></i>
</h5>


<p>
  <a name="94320"> </a><font face="Palatino, Times New Roman, Times, serif">You can call <code>setStopTime</code> to indicate when a <code>Player</code> should stop. The <code>Player</code> stops when its media time passes the specified stop time. If the <code>Player </code>object's<code> </code>rate is positive, the <code>Player</code> stops when the media time becomes greater than or equal to the stop time. If the <code>Player </code>object's rate is negative, the <code>Player</code> stops when the media time becomes less than or equal to the stop time. The <code>Player</code> stops immediately if its current media time is already beyond the specified stop time.</font>
</p>


<p>
  <a name="94323"> </a><font face="Palatino, Times New Roman, Times, serif">For example, assume that a <code>Player </code>object's media time is 5.0 and <code>setStopTime</code> is called to set the stop time to 6.0. If the <code>Player </code>object's rate is positive, media time is increasing and the <code>Player</code> will stop when the media time becomes greater than or equal to 6.0. However, if the <code>Player </code>object's rate is negative, it is playing in reverse and the <code>Player</code> will stop immediately because the media time is already beyond the stop time. (For more information about <code>Player</code> rates, see <a href="JMFPresenting.html#93857">Setting the Playback Rate</a>.)</font>
</p>


<p>
  <a name="94327"> </a><font face="Palatino, Times New Roman, Times, serif">You can always call <code>setStopTime</code> on a <em>Stopped</em> <code>Player</code>. However, you can only set the stop time on a <em>Started</em> <code>Player</code> if the stop time is not currently set. If the <em>Started</em> <code>Player</code> already has a stop time, <code>setStopTime</code> throws an error. </font>
</p>


<p>
  <a name="94328"> </a><font face="Palatino, Times New Roman, Times, serif">You can call <code>getStopTime</code> to get the currently scheduled stop time. If the clock has no scheduled stop time, <code>getStopTime</code> returns <code>Clock.RESET</code>. To remove the stop time so that the <code>Player</code> continues until it reaches end-of-media, call <code>setStopTime(Clock.RESET)</code>.</font>
</p>


<h4>
  <a name="93863"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Releasing Player Resources</font>
</h4>


<p>
  <a name="94424"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>deallocate</code> method tells a <code>Player</code> to release any exclusive resources and minimize its use of non-exclusive resources. Although buffering and memory management requirements for <code>Players</code> are not specified, most <code>Players</code> allocate buffers that are large by the standards of Java objects. A well-implemented <code>Player</code> releases as much internal memory as possible when <code>deallocate</code> is called.</font>
</p>


<p>
  <a name="94425"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>deallocate</code> method can only be called on a <em>Stopped</em> <code>Player</code>. To avoid <code>ClockStartedErrors</code>, you should call <code>stop</code> before you call <code>deallocate</code>. Calling <code>deallocate</code> on a <code>Player</code> in the <em>Prefetching</em> or <em>Prefetched</em> state returns it to the <em>Realized</em> state. If <code>deallocate</code> is called while the <code>Player</code> is realizing, the <code>Player</code> posts a <code>DeallocateEvent</code> and returns to the <em>Unrealized</em> state. (Once a <code>Player</code> has been realized, it can never return to the <em>Unrealized</em> state.)</font>
</p>


<p>
  <a name="94427"> </a><font face="Palatino, Times New Roman, Times, serif">You generally call <code>deallocate</code> when the <code>Player</code> is not being used. For example, an applet should call <code>deallocate</code> as part of its <code>stop</code> method. By calling <code>deallocate</code>, the program can maintain references to the <code>Player</code>, while freeing other resources for use by the system as a whole. (JMF does not prevent a <em>Realized</em> <code>Player</code> that has formerly been <em>Prefetched</em> or <em>Started</em> from maintaining information that would allow it to be started up more quickly in the future.)</font>
</p>


<p>
  <a name="94428"> </a><font face="Palatino, Times New Roman, Times, serif">When you are finished with a <code>Player</code> (or any other <code>Controller</code>) and are not going to use it anymore, you should call <code>close</code>. The <code>close</code> method indicates that the <code>Controller</code> will no longer be used and can shut itself down. Calling <code>close</code> releases all of the resources that the <code>Controller</code> was using and causes it to cease all activity. When a <code>Controller</code> is closed, it posts a <code>ControllerClosedEvent</code>. A closed <code>Controller</code> cannot be reopened and invoking methods on a closed <code>Controller</code> might generate errors.</font>
</p>


<h3>
  <a name="94764"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Querying a Player</font>
</h3>


<p>
  <a name="98075"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Player</code> can provide information about its current parameters, including its rate, media time, and duration.</font>
</p>


<h4>
  <a name="93865"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Getting the Playback Rate</font>
</h4>


<p>
  <a name="97921"> </a><font face="Palatino, Times New Roman, Times, serif">To get a <code>Player </code>object's current rate, you call <code>getRate</code>. Calling <code>getRate</code> returns the playback rate as a float value. </font>
</p>


<h4>
  <a name="93866"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Getting the Media Time</font>
</h4>


<p>
  <a name="94483"> </a><font face="Palatino, Times New Roman, Times, serif">To get a <code>Player</code> object's current media time, you call <code>getMediaTime</code>. Calling <code>getMediaTime</code> returns the current media time as a <code>Time</code> object. If the <code>Player</code> is not presenting media data, this is the point from which media presentation will commence. </font>
</p>


<p>
  <a name="98084"> </a><font face="Palatino, Times New Roman, Times, serif">Note that there is not a one-to-one correspondence between media times and frames. Each frame is presented for a certain period of time, and the media time continues to advance during that period. </font>
</p>


<p>
  <a name="94485"> </a><font face="Palatino, Times New Roman, Times, serif">For example, imagine you have a slide show <code>Player</code> that displays each slide for 5 seconds--the <code>Player</code> essentially has a frame rate of 0.2 frames per second. </font>
</p>


<a name="101594"> </a><font  size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/JMFPresentinga.gif" height="207" width="478">
<br></font>


<a name="101595"> </a><font  size="2" face="Palatino, Times New Roman, Times, serif">Figure 3-1:  Frame duration and media time.<br></font>


<p>
  <a name="101596"> </a><font face="Palatino, Times New Roman, Times, serif">If you start the <code>Player</code> at time 0.0, while the first frame is displayed, the media time advances from 0.0 to 5.0. If you start at time 2.0, the first frame is displayed for 3 seconds, until time 5.0 is reached.</font>
</p>


<h4>
  <a name="98085"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Getting the Time-Base Time</font>
</h4>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -