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();

}

}


本文标签: 侦听 状态 音频 编码 采集