QtExample没有播放视频的软件,如 http://blog.csdn.net/MicroSky2813/archive/2010/02/01/5275902.aspx 里面所说,只有个播放GIF的小软件,正好CSDN论坛上有问 Qt+ phonon播放视频的事,于是就写了这么个小东西
/*
* by microsky2813@hotmail.com
*
*/
#include<QApplication>
#include<phonon/videoplayer.h>
#include<phonon/mediasource.h>
#include<phonon/VideoWidget>
#include<phonon>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
Phonon::MediaObject *media = new Phonon::MediaObject();
Phonon::VideoWidget * vw=new Phonon::VideoWidget();//视频
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput();//声音
media->setCurrentSource(Phonon::MediaSource("10.wmv"));
Phonon::createPath(media, audioOutput);
Phonon::createPath(media,vw);
Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider(vw);
volumeSlider->setAudioOutput(audioOutput);
media->play();
vw->show();
return app.exec();
}