欢迎来到天天文库
浏览记录
ID:12981677
大小:38.00 KB
页数:3页
时间:2018-07-20
《java视频播放器源代码》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、importjava.awt.*;importjava.io.*;importjava.util.*;importjavax.media.*;importjavax.media.format.*;importjavax.swing.*;publicclassVideoPlayerimplementsControllerListener{VectoraudioCapDevList=null;VectorvideoCapDevList=null;CaptureDeviceInfoaudioCapDevInfo=null;CaptureD
2、eviceInfovideoCapDevInfo=null;MediaLocatoraudioCapDevLoc=null;MediaLocatorvideoCapDevLoc=null;PlayeraudioPlayer;PlayervideoPlayer;publicvoidinitAudioCapDevLoc(){//这里可以填写其它的音频编码格式,具体请看AudioFormat类audioCapDevList=CaptureDeviceManager.getDeviceList(newAudioFormat(AudioFor
3、mat.LINEAR));if((audioCapDevList.size()>0)){//或许有几个CaptureDevice,这里取第一个audioCapDevInfo=(CaptureDeviceInfo)audioCapDevList.elementAt(0);audioCapDevLoc=audioCapDevInfo.getLocator();}else{System.out.println("找不到音频采集设备");System.exit(0);}}publicvoidinitVideoCapDevLoc(){//这里
4、可以填写其它的编码视频格式,具体请看VideoFormat类videoCapDevList=CaptureDeviceManager.getDeviceList(newVideoFormat(VideoFormat.YUV));if((videoCapDevList.size()>0)){//或许有几个CaptureDevice,这里取第一个videoCapDevInfo=(CaptureDeviceInfo)videoCapDevList.elementAt(0);videoCapDevLoc=videoCapDevInfo.ge
5、tLocator();}else{System.out.println("找不到视频采集设备");System.exit(0);}}publicvoidinitAudioPlayer(){try{audioPlayer=Manager.createPlayer(audioCapDevLoc);}catch(NoPlayerExceptionex){}catch(IOExceptionex){}//增加一个侦听器,侦听player状态的改变audioPlayer.addControllerListener(this);audioPla
6、yer.realize();}publicvoidinitVideoPlayer(){try{videoPlayer=Manager.createPlayer(videoCapDevLoc);}catch(NoPlayerExceptionex){}catch(IOExceptionex){}//增加一个侦听器,侦听player状态的改变videoPlayer.addControllerListener(this);videoPlayer.realize();}publicvoidstopAndClosePlayer(){audio
7、Player.stop();audioPlayer.close();videoPlayer.stop();videoPlayer.close();}publicsynchronizedvoidcontrollerUpdate(ControllerEventce){Playerp=(Player)ce.getSourceController();JFramejFrame=newJFrame();Componentcom;if(p==null){return;}//如果player的状态变为Realizedif(ceinstanceof
8、RealizeCompleteEvent){if((com=p.getControlPanelComponent())!=null){jFrame.add(com,BorderLayout.SOUTH);}if((com=p.getV
此文档下载收益归作者所有