MediaPlayer Bean


JMF Documentation


Create an instance of MediaPlayer

To create an instance of the MediaPlayer component in a GUI builder environment, you must first import the MediaPlayer Bean to the GUI builder environments, e.g.IBM VisualAge for Java, and then drag the MediaPlayer icon to the free-form surface.

To create a MediaPlayer instance in Java code, enter:

MediaPlayer1 = new;
Set the media file location for MediaPlayer

If you are in a GUI builder environments, you can wire the the media file location via the "media location" property of the MediaPlayer.

To set the media location property in Java code, use the setMediaLocation method:

// Set the media location
MediaPlayer1.setMediaLocation(new java.lang.String("file:///E:/jvideo/media/"));

Start the instance of the MediaPlayer

To start the instance of the MediaPlayer, use the start method:


Stop the instance of the MediaPlayer

To stop the instance of the MediaPlayer, use the stop method:


To see a complete sample program using MediaPlayer see

MediaPlayer Bean Properties

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 loops continuously.
Media location  String N/A The location of the media URL. It can be an URL or a relative address.  For example:
  • file:///e:/video/media/
  • http://webServer/media/
  • media/
Show caching control  Boolean No Controls whether the caching progress bar is visible.
Fixed Aspect Ratio Boolean Yes Controls whether the media original fixed aspect ratio is maintained.
Volume int 3 Controls the audio volume.