您好,我正在尝试从该站点运行示例:http: //doc.qt.io/qt-5/videooverview.html 我的代码如下:
#include "mainwindow.h"
#include <QApplication>
#include <QVideoWidget>
#include <QMediaPlayer>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
playlist->addMedia(QUrl("http://example.com/myclip1.mp4"));
playlist->addMedia(QUrl("http://example.com/myclip2.mp4"));
videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);
videoWidget->show();
playlist->setCurrentIndex(1);
player->play();
return a.exec();
}
当我尝试执行它时,我得到了错误:
错误:在此范围内未声明“播放器” player = new QMediaPlayer; ^ /home/roman/Downloads/Dropbox/PAdI/GuiAppTest/untitled/main.cpp:15:错误:“播放列表”未在此范围内声明播放列表=新QMediaPlaylist(播放器);^ /home/roman/Downloads/Dropbox/PAdI/GuiAppTest/untitled/main.cpp:15:错误:无效使用不完整类型'class QMediaPlaylist'播放列表=新QMediaPlaylist(播放器);^ 我使用 Qt 5 和 QT 小部件模板。怎么了?