-
I am trying to learn multimedia programming in Qt and to start off I am trying to set up a very basic video player.
But this seems to be a challenge now in Qt6 due to major changes made in multimedia module.
While in Qt5 QMediaPlayer had the control over the volume, that has changed and now this is the job of the QAudioOutput and it has to be set by QMediaPlayer.
In this article it is explained the reason for this change and more others. Even though it is claimed that it is simplifying things, I am yet to see it. As of matter of fact I noticed that there are thing that worked fined in Qt5 but not anymore in Qt6, I am guessing this is normal when major releases are made.Anyway, I am using Qt6.2.0 and when instantiating the QAudioOuput object my app crahes and doesn't even start, seems to be some code in the constructor that it is causing it.
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); videoWidget = new QVideoWidget(this); videoWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); videoWidget->setMinimumHeight(0); // audioOutput = new QAudioOutput(this); mediaPlayer = new QMediaPlayer(this); mediaPlayer->setVideoOutput(videoWidget); mediaPlayer->setSource(QUrl::fromLocalFile("D:\\Videos\\Videos\\New\\Michael J - Bad.mp4")); // mediaPlayer->setAudioOutput(audioOutput); ui->stackedWidget->addWidget(videoWidget); ui->stackedWidget->setCurrentWidget(videoWidget); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { mediaPlayer->play(); }
If I uncomment
audioOutput = new QAudioOutput(this);
the app crashes before even starting.
QAudioOutput is only for the audio which means that without it the video will be mute but still play supposedly which doesn't happen still. If I click the button nothing happens while if I switch to Qt5 it works fine.I don't know if I am doing everything correctly according to Qt6 though. But the doc is still very incomplete as it can be seen here (there are some methods without documentation and needs to be update as it still uses the default example for Qt5 because here it is using the
setVolume
with the QMediaPlayer, that in Qt6 is not present anymore). It's seems that there's a lot work yet to be done.In the meantime, I am planning to build a full working video player so I can implement some features for personal use. But I am guessing that this is not possible for the time being with Qt 6 and I am very but VERY reluctant to use Qt5 for the simple feeling that I might be moving backwards and also I want my apps to accompany the Qt development as it moves forward.
Thoughts?
Edit:
I forgot to mention the platform, I am on Windows 10 21H1 -
Hi,
Did you already check the bug report system ?
Are you using the latest beta available ?
On which platform are you getting that issue ?
-
@SGaist said in QAudioOutput seems to crash my app - Qt6 QMediaPlayer/multimedia Problems:
Did you already check the bug report system ?
Yes, but didn't find anything. I want to write a bug report but I am looking for a feedback here to see if it's a really a bug or maybe I doing something wrong
Are you using the latest beta available ?
Yes.
On which platform are you getting that issue ?
Sorry I forgot to mention that in the OP, I am on Windows 10.
-
If just creating a QAudioOutput crashes your application then there's something wrong going on.
What is the stack trace of the crash ?
-
Please use a debug build to get a proper stack trace.
-
So you might be missing Qt's debug symbols as seeing the Disassembler view is unusual in a debug build.
-
Did you install the debug symbols ?
-
You can download the debug symbols from the maintenance tool.
-
Ok... If memory serves well, another beta has been released, did you check it ?
-
I would add a complete minimal compilable example the report. This would allow more people to help fixing that issue.