[英]C++: Media Player using Qt
I want to develop a media player using Qt. 我想用Qt开发一个媒体播放器。 On the basis of the documentation I have done the following things:
在文档的基础上,我做了以下事情:
pro file 专业档案
QT += core gui multimedia
QT += multimediawidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Player
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
main.cpp file main.cpp文件
#include <QApplication>
#include <QtMultimediaWidgets/QVideoWidget>
#include <QtMultimedia/QMediaPlayer>
#include <QtMultimedia/QMediaPlaylist>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMediaPlayer *player=new QMediaPlayer;
QVideoWidget *videowidget=new QVideoWidget;
QMediaPlaylist *playlist=new QMediaPlaylist;
playlist->addMedia(QUrl("C:/Users/Administrator/Desktop/VideoLAN/VLC/stram.mp4"));
player->setVideoOutput(videowidget);
playlist->setCurrentIndex(1);
player->setPlaylist(playlist);
player->play();
videowidget->show();
return a.exec();
}
As for the header file I have included mainwindow.h 至于头文件,我已经包含了mainwindow.h
EDIT 编辑
All the erorrs are gone but now the output which is coming is: 所有的人都消失了,但现在的输出是:
Where am I going wrong? 我哪里错了?
Try add this string to .pro file: 尝试将此字符串添加到.pro文件:
QT += multimediawidgets
for additional info: http://qt-project.org/doc/qt-5/qvideowidget.html 其他信息: http : //qt-project.org/doc/qt-5/qvideowidget.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.