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

📄 jmfpresenting.html

📁 jmf指导文件参考资料
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher 5.0.2">
<meta name="TEMPLATEBASE" content="Portable HTML">
<meta name="LASTUPDATED" content="11/23/99 11:48:04">
<title>Presenting Time-Based Media with JMF  </title>
</head>

<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">


<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="JMFTOC.html">CONTENTS</a> | 
    <a href="JMFArchitecture.html">PREV </a> |
    <a href="JMFProcessing.html">NEXT</a> |
    <a href="JMFIX.html">INDEX</a></td>
    <td align="right"><em>JMF 2.0 API Guide</em>
  </tr>
</table>

<p><br clear="all">
</p>

<hr align="left">

<blockquote>
<div align="right">
<a name="93848"> </a><font  size="3" face="Palatino, Times New Roman, Times, serif">3 <br></font>
</div>
<div align="right">
<h2>
  <a name="99999"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Presenting Time-Based Media with JMF</font>
</h2>
</div>

<p>
  <a name="94977"> </a><font face="Palatino, Times New Roman, Times, serif">To present time-based media such as audio or video with JMF, you use a <code>Player</code>. Playback can be controlled programmatically, or you can display a control-panel component that enables the user to control playback interactively. If you have several media streams that you want to play, you need to use a separate <code>Player</code> for each one. to play them in sync, you can use one of the <code>Player </code>objects to control the operation of the others.</font>
</p>


<p>
  <a name="97841"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Processor</code> is a special type of <code>Player</code> that can provide control over how the media data is processed before it is presented. Whether you're using a basic <code>Player</code> or a more advanced <code>Processor</code> to present media content, you use the same methods to manage playback. For information about how to control what processing is performed by a <code>Processor</code>, see <a href="JMFProcessing.html#97009">Processing Time-Based Media with JMF</a>.</font>
</p>


<p>
  <a name="99534"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>MediaPlayer</code> bean is a Java Bean that encapsulates a JMF player to provide an easy way to present media from an applet or application. The <code>MediaPlayer</code> bean automatically constructs a new <code>Player</code> when a different media stream is selected, which makes it easier to play a series of media clips or allow the user to select which media clip to play. For information about using the <code>MediaPlayer</code> bean, see <a href="JMFPresenting.html#98442">Presenting Media with the MediaPlayer Bean</a></font>
</p>


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


<p>
  <a name="94982"> </a><font face="Palatino, Times New Roman, Times, serif">To play a media stream, you need to construct a <code>Player</code> for the stream, configure the <code>Player</code> and prepare it to run, and then start the <code>Player</code> to begin playback.</font>
</p>


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


<p>
  <a name="94101"> </a><font face="Palatino, Times New Roman, Times, serif">You create a <code>Player</code> indirectly through the media <code>Manager</code>. To display the <code>Player</code>, you get the <code>Player </code>object's components and add them to your applet's presentation space or application window.</font>
</p>


<p>
  <a name="94120"> </a><font face="Palatino, Times New Roman, Times, serif">When you need to create a new <code>Player</code>, you request it from the <code>Manager</code> by calling <code>createPlayer or createProcessor</code>. The <code>Manager</code> uses the media <code>URL</code> or <code>MediaLocator</code> that you specify to create an appropriate <code>Player</code>. A <code>URL</code> can only be successfully constructed if the appropriate corresponding <code>URLStreamHandler</code> is installed. <code>MediaLocator</code> doesn't have this restriction.</font>
</p>


<h5>
  <a name="99798"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Blocking Until a Player is Realized</font></i>
</h5>


<p>
  <a name="99799"> </a><font face="Palatino, Times New Roman, Times, serif">Many of the methods that can be called on a <code>Player</code> require the <code>Player</code> to be in the <em>Realized</em> state. One way to guarantee that a <code>Player</code> is <em>Realized</em> when you call these methods is to use the <code>Manager</code> <code>createRealizedPlayer</code> method to construct the <code>Player</code>. This method provides a convenient way to create and realize a <code>Player</code> in a single step. When this method is called, it blocks until the <code>Player</code> is <em>Realized</em>. <code>Manager</code> provides an equivalent <code>createRealizeProcessor</code> method for constructing a <em>Realized</em> <code>Processor</code>.</font>
</p>


<p>
  <a name="99800"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>Note:</strong> Be aware that blocking until a <code>Player</code> or <code>Processor</code> is <em>Realized</em> can produce unsatisfactory results. For example, if <code>createRealizedPlayer</code> is called in an applet, <code>Applet.start </code>and <code>Applet.stop</code> will not be able to interrupt the construction process.</font>
</p>


<h5>
  <a name="97813"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Using a ProcessorModel to Create a Processor</font></i>
</h5>


<p>
  <a name="97817"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Processor</code> can also be created using a <code>ProcessorModel</code>. The <code>ProcessorModel</code> defines the input and output requirements for the <code>Processor</code> and the <code>Manager</code> does its best to create a <code>Processor</code> that meets these requirements. To create a <code>Processor</code> using a <code>ProcessorModel</code>, you call the <code>Manager.createRealizedProcessor </code>method. <a href="JMFPresenting.html#100511">Example 3-1</a> creates a <em>Realized</em> <code>Processor</code> that can produce IMA4-encoded stereo audio tracks with a 44.1 kHz sample rate and a 16-bit sample size.</font>
</p>


<a name="100602"> </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="100511"> </a>Example 3-1:  Constructing a Processor with a ProcessorModel.</font></i></b></caption>
  <tr>
    <td><font face="Palatino, Times New Roman, Times, serif"><pre>
<a name="100522"> </a>AudioFormat afs[] = new AudioFormat[1]; 
<a name="100538"> </a>afs[0] = new AudioFormat("ima4", 44100, 16, 2); 
<a name="100533"> </a>Manager.createRealizedProcessor(new ProcessorModel(afs, null)); 
</pre>
</font></td>
  </tr>
</table>



<br></font>


<p>
  <a name="98025"> </a><font face="Palatino, Times New Roman, Times, serif">Since the <code>ProcessorModel</code> does not specify a source URL in this example, <code>Manager</code> implicitly finds a capture device that can capture audio and then creates a <code>Processor</code> that can encode that into IMA4.</font>
</p>


<p>
  <a name="98022"> </a><font face="Palatino, Times New Roman, Times, serif">Note that when you create a <em>Realized</em> <code>Processor</code> with a <code>ProcessorModel</code> you will not be able to specify processing options through the <code>Processor</code> object's <code>TrackControls</code>. For more information about specifying processing options for a Processor, see <a href="JMFProcessing.html#97009">Processing Time-Based Media with JMF</a>.</font>
</p>


<h4>
  <a name="94196"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Displaying Media Interface Components</font>
</h4>


<p>
  <a name="94202"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Player</code> generally has two types of user interface components, a visual component and a control-panel component. Some <code>Player</code> implementations can display additional components, such as volume controls and download-progress bars.</font>
</p>


<h5>
  <a name="94198"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Displaying a Visual Component</font></i>
</h5>


<p>
  <a name="94211"> </a><font face="Palatino, Times New Roman, Times, serif">A visual component is where a <code>Player</code> presents the visual representation of its media, if it has one. Even an audio <code>Player</code> might have a visual component, such as a waveform display or animated character.</font>
</p>


<p>
  <a name="94212"> </a><font face="Palatino, Times New Roman, Times, serif">To display a <code>Player </code>object's<code> </code>visual component, you:</font>
</p>

<ol type="1">
  <li value="1"><a name="94214"> </a><font face="Palatino, Times New Roman, Times, serif">Get the component by calling <code>getVisualComponent</code>.</font>
  <li value="2"><a name="94215"> </a><font face="Palatino, Times New Roman, Times, serif">Add it to the applet's presentation space or application window.</font>
</ol>

<p>
  <a name="94217"> </a><font face="Palatino, Times New Roman, Times, serif">You can access the <code>Player </code>object's display properties, such as its <em>x</em> and <em>y</em> coordinates, through its visual component. The layout of the <code>Player</code> components is controlled through the AWT layout manager. </font>
</p>


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


<p>
  <a name="94227"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Player</code> often has a control panel that allows the user to control the media presentation. For example, a <code>Player</code> might be associated with a set of buttons to start, stop, and pause the media stream, and with a slider control to adjust the volume. </font>
</p>


<p>
  <a name="94229"> </a><font face="Palatino, Times New Roman, Times, serif">Every <code>Player</code> provides a default control panel. To display the<code> </code>default control panel:</font>
</p>

<ol type="1">
  <li value="1"><a name="96251"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>getControlPanelComponent </code>to get the <code>Component</code>. </font>
  <li value="2"><a name="96254"> </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>

⌨️ 快捷键说明

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