Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved QMediaPlayer doesn't start

    General and Desktop
    2
    6
    122
    Loading More Posts
    • 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.
    • A
      AndreasKwd last edited by

      Hello,

      I'm trying to create an instance of QMediaPlayer, but I always get an error in runtime.

      QMediaPlayer	player;
      

      I get the error message:

      The inferior stopped because it recieved a signal from the
      operating system.
      
      Signal name: ?
      Signam meaning: Unknown signal
      

      OS: aktuelles Windows 10

      QT:
      Qt Creator 4.14.0
      Based on Qt 5.12.2 (MSVC 2019, 64 bit)

      the .pro file contains:
      QT += core gui multimedia

      Has anybody an idea or coult help please?

      Thanks and regards
      Andreas

      1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        Please show some code. We can't know what you're doing without it...

        Qt has to stay free or it will die.

        1 Reply Last reply Reply Quote 0
        • A
          AndreasKwd last edited by

          void WndTemplBase::PlaySound(QString    _sFilename)
          {
              // the following line causes the runtime error!
              m_pPlayer  = new QMediaPlayer;       // member variable
          
              QUrl   urlTitle = QUrl::fromLocalFile(_sFilename);
          
              m_pPlayer->setMedia(urlTitle);
              m_pPlayer->setVolume(50);
              m_pPlayer->play();
          }
          
          1 Reply Last reply Reply Quote 0
          • Christian Ehrlicher
            Christian Ehrlicher Lifetime Qt Champion last edited by

            @AndreasKwd said in QMediaPlayer doesn't start:

            m_pPlayer = new QMediaPlayer;

            So you create a new QMediaPlayer every time PlaySound() is called? This doesn't look right.

            Qt has to stay free or it will die.

            1 Reply Last reply Reply Quote 0
            • A
              AndreasKwd last edited by

              No, I create it in the constructor. I just wanted to make it easier.
              The full code is:

              void WndTemplBase::WndTemplBase()
              {
                  // the following line causes the runtime error!
                  m_pPlayer  = new QMediaPlayer;       // member variable
              }
              
              void WndTemplBase::~WndTemplBase()
              {
                  delete m_pPlayer;
              }
              
              void WndTemplBase::PlaySound(QString    _sFilename)
              {
                  QUrl   urlTitle = QUrl::fromLocalFile(_sFilename);
              
                  m_pPlayer->setMedia(urlTitle);
                  m_pPlayer->setVolume(50);
                  m_pPlayer->play();
              }
              
              1 Reply Last reply Reply Quote 0
              • Christian Ehrlicher
                Christian Ehrlicher Lifetime Qt Champion last edited by

                Strange. Where do you instantiate WndTemplBase?
                What Qt version and OS do you use?

                Qt has to stay free or it will die.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post