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. QMediaPlayer doesn't start
Qt 6.11 is out! See what's new in the release blog

QMediaPlayer doesn't start

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 789 Views
  • 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 Offline
    A Offline
    AndreasKwd
    wrote on last edited by
    #1

    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
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AndreasKwd
        wrote on last edited by
        #3
        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
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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 Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AndreasKwd
            wrote on last edited by
            #5

            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
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

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

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              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