why QMediaPlayer can not play from QThread?
-
I am trying to play vedio file from another thread, but got application crash, and after i using windbg to analyze dump file , I found following message:
FAILURE_BUCKET_ID: NULL_POINTER_READ_c0000005_dsengine.dll!Unknown
//////////////////////////////////.h #ifndef TESTMEDIAPLAYER_H #define TESTMEDIAPLAYER_H #include <QObject> #include <QMediaPlayer> class TestMediaPlayer : public QObject { Q_OBJECT QMediaPlayer* player = nullptr; public: explicit TestMediaPlayer(QObject *parent = nullptr); signals: void play(); }; #endif // TESTMEDIAPLAYER_H //////////////////////////////////.h //////////////////////////////////cpp #include "TestMediaPlayer.h" TestMediaPlayer::TestMediaPlayer(QObject *parent) : QObject(parent) { player = new QMediaPlayer(this); connect(this, &TestMediaPlayer::play, this, [this](){ player->setMedia(QUrl::fromLocalFile("2021_05_06_10_59_00.flv")); player->play(); }, Qt::QueuedConnection); } //////////////////////////////////cpp //////////////////////////////////gui.cpp TestMediaPlayer* test = new TestMediaPlayer(); QThread* thread = new QThread; test->moveToThread(thread); thread->start(); test->play(); //////////////////////////////////gui.cpp
thanks for your help
-
Hi,
QMediaPlayer will render video data which is a GUI activity. This can only happen in the GUI thread.
There might also be backends that do not support that kind of setup. -
Hi,
QMediaPlayer will render video data which is a GUI activity. This can only happen in the GUI thread.
There might also be backends that do not support that kind of setup. -
Hi,
QMediaPlayer will render video data which is a GUI activity. This can only happen in the GUI thread.
There might also be backends that do not support that kind of setup.@SGaist
hello, can I ask more question?
today, I test two different version of Qt with the same code,
and I found my code will crash on Qt5.12.10 but on Qt5.14.2, It would work.
Is there any bug on Qt5.12 or something changed after Qt5.12, I read changed logs from Qt5.13.0 to Qt5.14.2 but could not notice which change will cause this. -
If it crashes on 12 then it's problably wrong on 14 as well. 14 may just be more tolerant of your bugs.
-
@SGaist
hello, can I ask more question?
today, I test two different version of Qt with the same code,
and I found my code will crash on Qt5.12.10 but on Qt5.14.2, It would work.
Is there any bug on Qt5.12 or something changed after Qt5.12, I read changed logs from Qt5.13.0 to Qt5.14.2 but could not notice which change will cause this. -
If it crashes on 12 then it's problably wrong on 14 as well. 14 may just be more tolerant of your bugs.
emmm.... you are right, today I find more evidence.
I found, my system is diffirent from my colleague. they are using win10 home or win10 professional version, my system is "win10 Enterprise ltsc" and they can run my code without crash. and I also installed two version of win10 in my virtualbox software. and also my code just crash on "win10 Enterprise ltsc"
-
@jsulm
thank you. this is a good idea
I had create windows dump file, could you tell me what information is helpful and I am using windbg debug tool