2023年7月11日发(作者:)
java播放器源码_java视频播放器源代码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的状态变为Realizedif (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();}}
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689065369a202190.html
评论列表(0条)