织梦CMS - 轻松建站从此开始!

罗索

当前位置: 主页>杂项技术>JAVA>

Java Media Framework 2.1 - MediaPlayer Bean

罗索客 发布于 2004-07-26 14:30 点击:次 
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
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)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/200407/419.html]
本文出处: 作者:iwgh
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容