Working with the JMF MultiPlayer Bean
Use the MultiPlayer Bean to add multiple video and audio playback capabilities of the Java Media Framework to your applets and applications. You can use the MultiPlayer Bean as a player to play several JMF supported media types. The MultiPlayer lets the designer provide a list of media to be selected and played by the end user. It also allows web designers to attach relevant links to each media so that if users would like more information on the current playing media, they can hyperlink to a related website.
Create an Instance of JMF MultiPlayer
To create an instance of the JMF
MultiPlayer component in a GUI builder environment, you must first import the JMF
MultiPlayer Bean to the GUI builder environment, e.g. Symantec Visual Cafe, and then drag
the JMF MultiPlayer icon to the
free-form surface.
To create a JMF MultiPlayer instance in Java code, enter:
import com.ibm.jmf.MultiPlayer.MultiPlayerBean; MultiPlayer1 = new com.ibm.jmf.MultiPlayer.MultiPlayerBean();
Add a Media Group for the MultiPlayer
A Media Group consists of a media name and button image name. If you are in a GUI builder environment, you can wire the the media name via the Media Group property of the JMF MultiPlayer, if available.
To set media name and button image name property in Java code, use the addMGroup method:
// Create a Media Group MultiPlayer1.addMGroup("file:///E:/jvideo/media/ASPEN1.mpg", "file:///E:/jvideo/media/ASPEN1.gif");
You can place this code in any appropriate method in your applet or application. For example, place the code in the init method.
Set a Related Link to a Media Group for the MultiPlayer
If you are in a GUI builder environments, you can wire the the media name via the Related Links property of the JMF MultiPlayer, if available.
To add a related link in Java code, get the Media Group and use the setRelated method:
// add a related link MediaGroup mg = MultiPlayer1.getMGroup(index); mg.setRelated(new RelatedLink("http://www.ibm.com/net.media", 0, 0, MultiPlayer1);
index
is the index of the Media Group to which the link should be added.Start the First Media Clip of the JMF MultiPlayer
To start the first media clip of the JMF MultiPlayer, use the start method:
MultiPlayer1.start();
The image buttons can also be pressed to switch to the other media clips. The former media pauses until selected again.
When any media clips are running in an applet, pressing the info button brings up a new browser window with the related links, if any were set.
Stop the Instance of the JMF MultiPlayer
To stop the instance of the JMF MultiPlayer, use the stop method:
MultiPlayer1.stop();
All the media clips will be stopped and memory will be deallocated.
To Free the Instance of the JMF MultiPlayer
To free the instance of the JMF MultiPlayer, use the destroy method:
MultiPlayer1.destroy();
All the media clips stop, close, and memory is deallocated.
To see examples of more advanced tasks see JMF MultiPlayer Samples.
Providing Related Links to Media Groups and Applets
The MultiPlayer Bean can provide
related links to each Media Group that it holds. The Media
Group contains:
Related links are time-based links associated with a particular Media Group. You can specify that if, during a certain time in the playing of the media the user presses the info button, a new browser window opens with the associated link. Related links can only be active in Web browsers; they will not work in the AppletViewer or in applications.
Property Name | Type | Default | Property Description |
---|---|---|---|
Show control panel | Boolean | Yes | Controls whether the video control panel is visible. |
Loop | Boolean | Yes | Controls whether the Video or Audio loop scontinuously. |
Load all on initialization | Boolean | No | Controls if all the media should be loaded during the beginning. |
Show media name | Boolean | Yes | Controls if the media location will be visible during runtime. |
Media Group | MediaGroup | N/A | The
Media Group consists of the media URL and the button image URL. It can be an URL or
a relative address. e.g:
During runtime, the MultiPlayer creates a player associated with the given media URL and Image Button associated with the button image URL. If no button image URL is provided, the index of the Media Group will be shown on the button. |
Related Links | RelateLink | N/A | Related Links are the links that are relevant to the individual Media Groups. They can be added through the Related Links Custom Editor by enter the Media Group it is related to, the URL for the link, and the start and stop time the link is relevant during the playing of the media. |