admin 管理员组文章数量: 887021
2024年2月23日发(作者:diallog)
import .*;
import .*;
import .*;
import .*;
import .*;
import .*;
public class VideoPlayer implements ControllerListener {
Vector audioCapDevList = null;
Vector videoCapDevList = null;
CaptureDeviceInfo audioCapDevInfo = null;
CaptureDeviceInfo videoCapDevInfo = null;
MediaLocator audioCapDevLoc = null;
MediaLocator videoCapDevLoc = null;
Player audioPlayer;
Player videoPlayer;
public void initAudioCapDevLoc() {
//这里可以填写其它的音频编码格式,具体请看AudioFormat类
audioCapDevList = iceList(new
AudioFormat(
));
if ((() > 0)) {
//或许有几个CaptureDevice,这里取第一个
audioCapDevInfo = (CaptureDeviceInfo)
tAt(0);
audioCapDevLoc = ator();
} else {
n("找不到音频采集设备");
(0);
}
}
public void initVideoCapDevLoc() {
//这里可以填写其它的编码视频格式,具体请看VideoFormat类
videoCapDevList = iceList(new
VideoFormat(
));
if ((() > 0)) {
//或许有几个CaptureDevice,这里取第一个
videoCapDevInfo = (CaptureDeviceInfo)
tAt(0);
videoCapDevLoc = ator();
} else {
n("找不到视频采集设备");
(0);
}
}
public void initAudioPlayer() {
try {
audioPlayer = Player(audioCapDevLoc);
} catch (NoPlayerException ex) {
} catch (IOException ex) {
}
//增加一个侦听器,侦听player状态的改变
trollerListener(this);
e();
}
public void initVideoPlayer() {
try {
videoPlayer = Player(videoCapDevLoc);
} catch (NoPlayerException ex) {
} catch (IOException ex) {
}
//增加一个侦听器,侦听player状态的改变
trollerListener(this);
e();
}
public void stopAndClosePlayer(){
();
();
();
();
}
public synchronized void controllerUpdate(ControllerEvent ce) {
Player p = (Player) rceController();
JFrame jFrame = new JFrame();
Component com;
if (p == null) {
return;
}
//如果player的状态变为Realized
if (ce instanceof RealizeCompleteEvent) {
if ((com = trolPanelComponent()) != null) {
(com, );
}
if ((com = ualComponent()) != null) {
(com, );
}
ible(true);
();
aultCloseOperation(_ON_CLOSE);
();
}
}
public static void main(String args[]) {
VideoPlayer cap = new VideoPlayer();
dioCapDevLoc();
deoCapDevLoc();
dioPlayer();
deoPlayer();
try {
tThread().sleep(20000);//20秒后停止并关闭播放器
} catch (InterruptedException ex) {
}
dClosePlayer();
}
}
版权声明:本文标题:java视频播放器源代码 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1708634912h528265.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论