TAG:
JMF Documentation Create an Instance of MediaPlayer Set the Media File Location for MediaPlayer Start the Instance of MediaPlayer Stop the Instance of MediaPlayer MediaPlayer Bean Properties 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")); You can place this code in any appropriate method in your applet or application. For example, place the code in the init method. Start the instance of the MediaPlayer To start the instance of the MediaPlayer, use the start method: MediaPlayer1.start(); You can create a start button in your applet or application to connect to the start method in MediaPlayer Bean, the media file starts playing when you click on the button. Or you can connect the start method to the applet or application directly, so the media file starts when the applet or application starts. Stop the instance of the MediaPlayer To stop the instance of the MediaPlayer, use the stop method: MediaPlayer1.stop(); You can create a stop button in your applet or application to connect to the stop method in the MediaPlayer Bean. Tthe media file stops playing when you click on the button. Or you can connect the stop method to the applet or application directly, so the media file stops when the applet or application stops. 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. (iwgh) |