我没找到Ubuntu Linux视屏的api,所以调用QT里面phonon这个类实现视屏播放,首先搭建环境:
sudo apt-get install qt4-dev-tools qt4-designer qt4-doc qt4-qtconfig qt4-demos qt4-qmake libqt4-sql-mysql qdevelop
sudo apt-get install qtcreator
sudo apt-get install libphonon-dev libphonon4 phonon-backend-gstreamer
环境搭建好了了就创建一个工程,测试一个小例子
我的视屏文件存放路径是/home/leaf/1.mpg
#include <QApplication>
#include <QWidget>
#include <phonon>
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
app.setApplicationName(“VideoPlayer”);
QWidget *widget=new QWidget;
widget->resize(600,400);
Phonon::VideoPlayer *player=new Phonon::VideoPlayer(Phonon::VideoCategory,widget);
player->load(Phonon::MediaSource(“/home/leaf/1.mpg”));
player->play();
widget->show();
return app.exec();
}
最后编译的时候在.pro文件里加上QT += phonon