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:

  1. Create a project, a package, and an applet
  2. Add a JMF MultiPlayer Bean to the applet
  3. 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

  1. 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.
  2. Make sure that you have imported both the JMFPlayer Bean and the JMF MultiPlayer Beans in your project.
  3. 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.
  4. 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.
  5. From the File menu, choose the Import menu item. A SmartGuide Import dialog box displays.
  6. Click on the JAR file option; then click on the Next button.
  7. 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.
  8. Import MultiPlayer Bean by repeating steps 5-7 with the multiplayer.jar.
  9. Add the MultiPlayer Bean to the bean palette by selecting menu Bean | Modify Palette...
    A Modify Palette dialog box displays.
  10. 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.
  11. 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:

  1. 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.
  2. Right-click on the MultiPlayer1 bean instance, and select Properties on the pop-up menu. The MultiPlayer1 property window displays.
  3. 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.
  4. 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.
  5. 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.
  6. Add more Media Groups or click OK to exit the Media Array Editor.

Running the applet:

  1. 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.
  2. You can adjust the volume, play backward and forward, pause, and restart from the control component in the applet window.
  3. If you want to save the project, choose Save workspace from the File menu.

IBM Corporation 1996, 1998