Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. why QMediaPlayer can not play from QThread?
Forum Updated to NodeBB v4.3 + New Features

why QMediaPlayer can not play from QThread?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MozzieM Offline
    MozzieM Offline
    Mozzie
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      MozzieM 2 Replies Last reply
      2
      • SGaistS SGaist

        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.

        MozzieM Offline
        MozzieM Offline
        Mozzie
        wrote on last edited by
        #3

        @SGaist
        thank you very much

        1 Reply Last reply
        0
        • SGaistS SGaist

          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.

          MozzieM Offline
          MozzieM Offline
          Mozzie
          wrote on last edited by
          #4

          @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.

          jsulmJ 1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            If it crashes on 12 then it's problably wrong on 14 as well. 14 may just be more tolerant of your bugs.

            I light my way forward with the fires of all the bridges I've burned behind me.

            MozzieM 1 Reply Last reply
            1
            • MozzieM Mozzie

              @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.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Mozzie You should post the stack trace after crash, else only guessing is possible.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              MozzieM 1 Reply Last reply
              0
              • Kent-DorfmanK Kent-Dorfman

                If it crashes on 12 then it's problably wrong on 14 as well. 14 may just be more tolerant of your bugs.

                MozzieM Offline
                MozzieM Offline
                Mozzie
                wrote on last edited by
                #7

                @Kent-Dorfman @SGaist @jsulm

                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"

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Mozzie You should post the stack trace after crash, else only guessing is possible.

                  MozzieM Offline
                  MozzieM Offline
                  Mozzie
                  wrote on last edited by
                  #8

                  @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

                  jsulmJ 1 Reply Last reply
                  0
                  • MozzieM Mozzie

                    @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

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Mozzie Useful is the stack trace

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved