Creating a JMF MultiPlayer Applet in VisualAge for Java
Estimated Time Required: 10
minutes
In this sample, you use VisualAge for
Java to create a simple applet that lets you view one media clip with a corresponding
button that selects the clip. You do not have to write any code. You use VisualAge for
Java to:
- Create a project, a package, and an applet
- Add a JMF MultiPlayer Bean
to the applet
- Run
the applet
Before you begin, make sure you installed both the
JMFPlayer and the JMF MultiPlayer Beans in VisualAge for Java.
Creating
the Project
- Create a new project by selecting
Quick Start from the File menu. When the Quick Start dialog box appears,
click Create Applet under the Basic column, then click the OK
button.
- Make sure that you have imported both
the JMFPlayer Bean and the JMF MultiPlayer Beans in your project.
- If you have installed both beans into a
project, enter that project name in the SmartGuide dialog box. A Composition
Editor panel displays. Skip the next four steps.
- If you have not installed both beans, a
new dialog box SmartGuide appears. Fill out Project, Package and Applet name
fields, such as "JMFTest". A Composition Editor panel displays in the JMFTest
window.
- From the File menu, choose the Import
menu item. A SmartGuide Import dialog box displays.
- Click on the JAR file option;
then click on the Next button.
- Select JMFPlayer.jar from the directory
where you extracted the files from the JMFPlayer.zip file. The project
name should display as JMFTest automatically. Click the Finish
button, the JMFPlayer.jar file starts to be imported into VisualAge for Java.
- Import MultiPlayer Bean by repeating
steps 5-7 with the multiplayer.jar.
- Add the MultiPlayer Bean to the bean
palette by selecting menu Bean | Modify Palette...
A Modify Palette dialog box displays.
- Click Browse in the New bean
group box. In the Choose a valid class dialog box, click MultiPlayer
under the Class Names: list and com.ibm.jmf.MultiPlayer shows in Package Names:
list automatically. Click OK to exit. The Class name: textfield
in the Modify Palette dialog box fills with com.ibm.jmf.MultiPlayer.MultiPlayerBean
automatically.
- Click the New Category button in
Palette group box, and enter JMF to replace <new category> string.
Add to Category button now is enabled, click it.
MultiPlayer Bean now displays under JMF folder in Palette
group box. Click OK.
The MultiPlayer Bean Icon
is
displayed under JMF category of the bean palette.
Adding a JMF MultiPlayer Bean to the applet:
- Drag and drop the MultiPlayer Icon
from the JMF palette to the JMFTest
composition area and adjust it to your desired size. The instance of MultiPlayer called
MultiPlayer1 has been created.
- Right-click on the MultiPlayer1 bean
instance, and select Properties on the pop-up menu. The MultiPlayer1
property window displays.
- Click the Media Group property to
enter a media group. A Media Group consists of the media location and button image
location. A Media Array Editor pops up.
- In Media Array Editor, choose a
protocol, (http://, file:/// or codebase/) from the choice menu. You
can enter the media location as follows:
file:///<drive>:/<dir>/Sample1.mov
http://xena.cupertino.ibm.com/media/Sample1.mov
Note: The codebase/ option is only
supported for an applet. The media file address you entered is relative to the codebase
specified in the html file.
- You can enter the button image location the same as for the media location. If no
button image location is entered, a button with the index corresponding to the Media Group
is created.
- Add more Media Groups or click OK to exit the Media Array Editor.
Running the applet:
- Run the applet by selecting Bean
| Run | In Applet Viewer... and click any of the image buttons to start playing the
video in the applet window.
- You can adjust the volume, play backward
and forward, pause, and restart from the control component in the applet window.
- If you want to save the project, choose Save
workspace from the File menu.