基于QT视频软件的开发和学习(共9页).doc
《基于QT视频软件的开发和学习(共9页).doc》由会员分享,可在线阅读,更多相关《基于QT视频软件的开发和学习(共9页).doc(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上基于QT视频软件的开发和学习 马上工作需要做视频软件了,所以准备学习QT来开发,为什么选择QT呢,因为他优点多多(不说了自己网上g一下) 随着高清的不断普及,所有视频软件都向高清这个方向而前进,其中有一款开源跨平台的播放器vlc的特性和功能都是非常的好,所以想准备学习vlc的源码来看看,在看他源码的时候,发现他还有一个可供开发人员调用的libvlc 媒体库可用(GPL),而vlc本身使用的GUI就是QT。 好了不多说了 先装好QT SDK,然后把环境变量设置一下(不会去G!) 然后把vlc库加入到mingw里面 先复制vlc-include.rar解压出来的头文件到Q
2、t2009.04mingwinclude里面 在把vlc-lib.rar解压出来的文件放到C:vlc-lib 我们在 Qt Creator 里面建立一个空的QT项目 新建一个Player类 ,会多出player.cpp,player.h 修改成如下player.cppCpp代码 /* * Flie Name player.cpp */ #include player.h #include <QVBoxLayout> #include <QPushButton> #include <QSlider> #include <QTimer> #inclu
3、de <QFrame> Player:Player() : QWidget() /preparation of the vlc command const char * const vlc_args = -I, dummy, /* Dont use any interface */ -ignore-config, /* Dont use VLCs config */ -extraintf=logger, /log anything -verbose=2, /be much more verbose then normal for debugging purpose -plugin-
4、path=C:vlc-0.9.9-win32plugins ; _videoWidget=new QFrame(this); _volumeSlider=new QSlider(Qt:Horizontal,this); _volumeSlider->setMaximum(100); /the volume is between 0 and 100 _volumeSlider->setToolTip(Audio slider); / Note: if you use streaming, there is no ability to use the position slider _
5、positionSlider=new QSlider(Qt:Horizontal,this); _positionSlider->setMaximum(POSITION_RESOLUTION); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(_videoWidget); layout->addWidget(_positionSlider); layout->addWidget(_volumeSlider); setLayout(layout); _isPlaying=false; poller=new
6、QTimer(this); /Initialize an instance of vlc /a structure for the exception is neede for this initalization libvlc_exception_init(&_vlcexcep); /create a new libvlc instance _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args0), vlc_args,&_vlcexcep); /tricky calculation of the char spa
7、ce used raise (&_vlcexcep); / Create a media player playing environement _mp = libvlc_media_player_new (_vlcinstance, &_vlcexcep); raise (&_vlcexcep); /connect the two sliders to the corresponding slots (uses Qts signal / slots technology) connect(poller, SIGNAL(timeout(), this, SLOT(upd
8、ateInterface(); connect(_positionSlider, SIGNAL(sliderMoved(int), this, SLOT(changePosition(int); connect(_volumeSlider, SIGNAL(sliderMoved(int), this, SLOT(changeVolume(int); poller->start(100); /start timer to trigger every 100 ms the updateInterface slot /desctructor Player:Player() /* Stop pl
9、aying */ libvlc_media_player_stop (_mp, &_vlcexcep); /* Free the media_player */ libvlc_media_player_release (_mp); libvlc_release (_vlcinstance); raise (&_vlcexcep); void Player:playFile(QString file) /the file has to be in one of the following formats /perhaps a little bit outdated) /* fil
10、e:/filename Plain media file http:/ip:port/file HTTP URL ftp:/ip:port/file FTP URL mms:/ip:port/file MMS URL screen:/ Screen capture dvd:/deviceraw_device DVD device vcd:/device VCD device cdda:/device Audio CD device udp:<source address><bind address>:<bind port> */ /* Create a ne
11、w LibVLC media descriptor */ _m = libvlc_media_new (_vlcinstance, file.toAscii(), &_vlcexcep); raise(&_vlcexcep); libvlc_media_player_set_media (_mp, _m, &_vlcexcep); raise(&_vlcexcep); / /! Please note /! / / passing the widget to the lib shows vlc at which position it should show u
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 QT 视频 软件 开发 学习
限制150内