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

📄 jmfpresenting.html

📁 奉献给多媒体java编程者们。JMF2.1.1最新版本的用户指南。JMF是java用于基于实时多媒体的开发工具
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</ol>

<p>
  <a name="96259"> </a><font face="Palatino, Times New Roman, Times, serif">If you prefer to define a custom user-interface, you can implement custom GUI <code>Components</code> and call the appropriate <code>Player</code> methods in response to user actions. If you register the custom components as <code>ControllerListeners</code>, you can also update them when the state of the <code>Player</code> changes.</font>
</p>


<h5>
  <a name="94251"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Displaying a Gain-Control Component</font></i>
</h5>


<p>
  <a name="94254"> </a><font face="Palatino, Times New Roman, Times, serif"><code>Player </code>implementations that support audio gain adjustments implement the <code>GainControl</code> interface. <code>GainControl</code> provides methods for adjusting the audio volume, such as <code>setLevel</code> and <code>setMute</code>. To display a <code>GainControl Component</code> if the <code>Player</code> provides one, you:</font>
</p>

<ol type="1">
  <li value="1"><a name="96290"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>getGainControl</code> to get the <code>GainControl</code> from the <code>Player</code>. If the <code>Player</code> returns null, it does not support the <code>GainControl</code> interface.</font>
  <li value="2"><a name="96303"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>getControlComponent</code> on the returned <code>GainControl</code>.</font>
  <li value="3"><a name="96304"> </a><font face="Palatino, Times New Roman, Times, serif">Add the returned <code>Component</code> to your applet's presentation space or application window. </font>
</ol>

<p>
  <a name="96332"> </a><font face="Palatino, Times New Roman, Times, serif">Note that <code>getControls</code> does not return a <code>Player </code>object's <code>GainControl</code>. You can only access the <code>GainControl</code> by calling <code>getGainControl</code>.</font>
</p>


<h5>
  <a name="96333"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Displaying Custom Control Components</font></i>
</h5>


<p>
  <a name="96268"> </a><font face="Palatino, Times New Roman, Times, serif">Many <code>Players</code> have other properties that can be managed by the user. For example, a video <code>Player</code> might allow the user to adjust brightness and contrast, which are not managed through the <code>Player</code> interface. You can find out what custom controls a <code>Player</code> supports by calling the <code>getControls</code> method.</font>
</p>


<p>
  <a name="96270"> </a><font face="Palatino, Times New Roman, Times, serif">For example, you can call <code>getControls </code>to determine if a <code>Player</code> supports the <code>CachingControl</code> interface. </font>
</p>


<a name="100562"> </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"><a name="100565"> </a>Example 3-2:  Using getControls to find out what Controls are supported.</font></i></b></caption>
  <tr>
    <td><font face="Palatino, Times New Roman, Times, serif"><pre>
<a name="100573"> </a>Control[] controls = player.getControls();
<a name="100574"> </a>   for (int i = 0; i &lt; controls.length; i++) {
<a name="100575"> </a>      if (controls[i] instanceof CachingControl) {
<a name="100576"> </a>         cachingControl = (CachingControl) controls[i];
<a name="100577"> </a>      }
<a name="100578"> </a>   } 
</pre>
</font></td>
  </tr>
</table>



<br></font>


<h5>
  <a name="94260"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Displaying a Download-Progress Component</font></i>
</h5>


<p>
  <a name="96379"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>CachingControl</code> interface is a special type of <code>Control</code> implemented by <code>Players </code>that can report their download progress. A <code>CachingControl</code> provides a default progress-bar component that is automatically updated as the download progresses. To use the default progress bar in an applet:</font>
</p>

<ol type="1">
  <li value="1"><a name="94272"> </a><font face="Palatino, Times New Roman, Times, serif">Implement the <code>ControllerListener</code> interface and listen for<br><code>CachingControlEvents</code> in <code>controllerUpdate</code>.</font>
  <li value="2"><a name="98236"> </a><font face="Palatino, Times New Roman, Times, serif">The first time you receive a <code>CachingControlEvent:</code></font>
  <ol type="a">
    <li><a name="98243"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>getCachingControl</code> on the event to get the caching control.</font>
    <li><a name="98238"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>getProgressBar</code> on the <code>CachingControl</code> to get the default progress bar component.</font>
    <li><a name="98248"> </a><font face="Palatino, Times New Roman, Times, serif">Add the progress bar component to your applet's presentation space.</font>
  </ol>
  <li value="3"><a name="94277"> </a><font face="Palatino, Times New Roman, Times, serif">Each time you receive a <code>CachingControlEvent</code>, check to see if the download is complete. When <code>getContentProgress</code> returns the same value as <code>getContentLength</code>, remove the progress bar.</font>
</ol>

<p>
  <a name="96373"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>Player</code> posts a <code>CachingControlEvent</code> whenever the progress bar needs to be updated. If you implement your own progress bar component, you can listen for this event and update the download progress whenever <code>CachingControlEvent</code> is posted.</font>
</p>


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


<p>
  <a name="101644"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>Player </code>object's rate determines how media time changes with respect to time-base time; it defines how many units a <code>Player </code>object's media time advances for every unit of time-base time. The <code>Player </code>object's rate can be thought of as a temporal scale factor. For example, a rate of 2.0 indicates that media time passes twice as fast as the time-base time when the <code>Player</code> is started. </font>
</p>


<p>
  <a name="94544"> </a><font face="Palatino, Times New Roman, Times, serif">In theory, a <code>Player </code>object's rate could be set to any real number, with negative rates interpreted as playing the media in reverse. However, some media formats have dependencies between frames that make it impossible or impractical to play them in reverse or at non-standard rates. </font>
</p>


<p>
  <a name="94547"> </a><font face="Palatino, Times New Roman, Times, serif">To set the rate, you call <code>setRate</code> and pass in the temporal scale factor as a float value. When <code>setRate</code> is called, the method returns the rate that is actually set, even if it has not changed. <code>Players</code> are only guaranteed to support a rate of 1.0.</font>
</p>


<h4>
  <a name="93858"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Setting the Start Position</font>
</h4>


<p>
  <a name="94558"> </a><font face="Palatino, Times New Roman, Times, serif">Setting a <code>Player </code>object's media time is equivalent to setting a read position within a media stream. For a media data source such as a file, the media<em> </em>time is bounded; the maximum media time is defined by the end of the media stream. </font>
</p>


<p>
  <a name="94559"> </a><font face="Palatino, Times New Roman, Times, serif">To set the media time you call <code>setMediaTime</code> and pass in a<code> Time </code>object that represents the time you want to set.</font>
</p>


<h5>
  <a name="98264"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Frame Positioning</font></i>
</h5>


<p>
  <a name="98357"> </a><font face="Palatino, Times New Roman, Times, serif">Some <code>Players</code> allow you to seek to a particular frame of a video. This enables you to easily set the start position to the beginning of particular frame without having to specify the exact media time that corresponds to that position. <code>Players</code> that support frame positioning implement the <code>FramePositioningControl</code>. </font>
</p>


<p>
  <a name="98388"> </a><font face="Palatino, Times New Roman, Times, serif">To set the frame position, you call the <code>FramePositioningControl</code> <code>seek</code> method. When you seek to a frame, the <code>Player </code>object's media time is set to the value that corresponds to the beginning of that frame and a <code>MediaTimeSetEvent</code> is posted. </font>
</p>


<p>
  <a name="102140"> </a><font face="Palatino, Times New Roman, Times, serif">Some <code>Players</code> can convert between media times and frame positions. You can use the <code>FramePositioningControl</code> <code>mapFrameToTime</code> and <code>mapTimeToFrame</code> methods to access this information, if it's available. (<code>Players</code> that support <code>FramePositioningControl</code> are not required to export this information.) Note that there is not a one-to-one correspondence between media times and frames --a frame has a duration, so several different media times might map to the same frame. (See <a href="JMFPresenting.html#93866">Getting the Media Time</a> for more information.) - </font>
</p>


<h4>
  <a name="93859"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Preparing to Start</font>
</h4>


<p>
  <a name="94342"> </a><font face="Palatino, Times New Roman, Times, serif">Most media <code>Players</code> cannot be started instantly. Before the <code>Player</code> can start, certain hardware and software conditions must be met. For example, if the <code>Player</code> has never been started, it might be necessary to allocate buffers in memory to store the media data. Or, if the media data resides on a network device, the <code>Player</code> might have to establish a network connection before it can download the data. Even if the <code>Player</code> has been started before, the buffers might contain data that is not valid for the current media position.</font>
</p>


<h5>
  <a name="93860"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Realizing and Prefetching a Player</font></i>
</h5>


<p>
  <a name="94349"> </a><font face="Palatino, Times New Roman, Times, serif">JMF breaks the process of preparing a <code>Player</code> to start into two phases, <em>Realizing</em> and <em>Prefetching</em>. <em>Realizing</em> and <em>Prefetching</em> a <code>Player</code> before you start it minimizes the time it takes the <code>Player</code> to begin presenting media when <code>start</code> is called and helps create a highly-responsive interactive experience for the user. Implementing the <code>ControllerListener</code> interface allows you to control when these operations occur. </font>
</p>


<p>
  <a name="98256"> </a><font face="Palatino, Times New Roman, Times, serif">Note:  <code>Processor</code> introduces a third phase to the preparation process called <em>Configuring. </em>During this phase, <code>Processor</code> options can be selected to control how the <code>Processor</code> manipulates the media data. For more information, see <a href="JMFProcessing.html#96787">Selecting Track Processing Options</a>.</font>
</p>


<p>
  <a name="94351"> </a><font face="Palatino, Times New Roman, Times, serif">You call <code>realize </code>to move the <code>Player</code> into the <em>Realizing</em> state and begin the realization process. You call <code>prefetch</code> to move the <code>Player</code> into the <em>Prefetching</em> state and initiate the prefetching process. The <code>realize</code> and <code>prefetch</code> methods are asynchronous and return immediately. When the <code>Player</code> completes the requested operation, it posts a <code>RealizeCompleteEvent </code>or<code> PrefetchCompleteEvent</code>. <a href="JMFArchitecture.html#112886">Player States</a> describes the operations that a <code>Player</code> performs in each of these states. </font>
</p>


<p>
  <a name="94359"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Player</code> in the <em>Prefetched</em> state is prepared to start and its start-up latency cannot be further reduced. However, setting the media time through <code>setMediaTime</code> might return the <code>Player</code> to the <em>Realized</em> state and increase its start-up latency.</font>
</p>


<p>
  <a name="94361"> </a><font face="Palatino, Times New Roman, Times, serif">Keep in mind that a <em>Prefetched</em> <code>Player</code> ties up system resources. Because some resources, such as sound cards, might only be usable by one program at a time, having a <code>Player</code> in the <em>Prefetched</em> state might prevent other <code>Players</code> from starting.</font>
</p>


⌨️ 快捷键说明

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