PDA

View Full Version : QMediaPlayer problems



alenn.masic
20th February 2013, 13:59
Hi

I installed Qt5 and since Phonon is not supported in Qt5 I'm forced to use something else, so I decided to use QtMultimedia.

.pro file:


QT += core gui
CONFIG += mobility
MOBILITY += multimedia

.cpp code:


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>
#include <QtCore>
#include <QtMultimedia/QMediaPlayer>

...

void MainWindow::on_pushButton_clicked()
{
QMediaPlayer *player = new QMediaPlayer(this);
player->setVolume(50);
player->setMedia(QUrl::fromLocalFile("some_path"));
player->play();
}

But I'm getting following errors:

8743

How can I solve this. Thank you

Vlavv
25th February 2013, 16:32
Hi,

Using Qt5, your .pro file should look like this:

QT += multimedia
... or:

QT += multimedia multimediawidgets
... if you plan to use QVideoWidget for video rendering.

AFAIK, you don't need to set CONFIG and MOBILITY anymore with Qt5.

Cheers.

EDIT : by the way, you don't need to specify the module path in your #include. The standard way is to simply #include <QMediaPlayer>.