-2

Hello I am trying to get to run the example from this site: http://doc.qt.io/qt-5/videooverview.html My code is the following:

#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();



}

When I try to execute it I get the errors:

error: 'player' was not declared in this scope player = new QMediaPlayer; ^ /home/roman/Downloads/Dropbox/PAdI/GuiAppTest/untitled/main.cpp:15: error: 'playlist' was not declared in this scope playlist = new QMediaPlaylist(player); ^ /home/roman/Downloads/Dropbox/PAdI/GuiAppTest/untitled/main.cpp:15: error: invalid use of incomplete type 'class QMediaPlaylist' playlist = new QMediaPlaylist(player); ^ I use Qt 5 and QT widget template. What is wrong?

Rareform
  • 77
  • 1
  • 2
  • 11

2 Answers2

2

The error os correct, you need to declare player and playlist (probably at the begin of main):

QMediaPlayer* player;
QMediaPlaylist* playlist;
0

Sorry, I just learned that these examples are probably not c++ based, therefore they dont work... It works if one adjusts the commands

Rareform
  • 77
  • 1
  • 2
  • 11
  • 1
    Yes, it is C++. The example is not a complete program, just an example of how to use the class. – Leiaz May 17 '15 at 19:36