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:

             
               
import javax.media.bean.playerbean.MediaPlayer;
MediaPlayer1 = new javax.media.bean.playerbean.MediaPlayer();
            
          
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/Sample1.mov"));
            
          

Start the instance of the MediaPlayer

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

             
               
MediaPlayer1.start();
            
          

Stop the instance of the MediaPlayer

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

             
               
MediaPlayer1.stop();
            
          

To see a complete sample program using MediaPlayer see MediaPlayerSample.java

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/Sample1.mov
  • http://webServer/media/Sample1.mov
  • media/Sample1.mov
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.