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. QAudioProbe not working with QMediaPlayer
QtWS25 Last Chance

QAudioProbe not working with QMediaPlayer

Scheduled Pinned Locked Moved Unsolved General and Desktop
media playeraudio
7 Posts 4 Posters 3.1k 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.
  • C Offline
    C Offline
    cweeks
    wrote on 1 Nov 2015, 21:58 last edited by
    #1

    I am using a QMediaPlayer to play back an mp3 file, and I wish to set a QAudioProbe to monitor the output. However, my call to setSource() always returns false in the following:

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow) {
        ui->setupUi(this);
        x = new QVector<double>(256);
        y = new QVector<double>(256);
        values = new int[256];
    
        player = new QMediaPlayer();
    
        player->setMedia(QUrl::fromLocalFile(
                         "C:/Users/Person1/Desktop/piano.mp3"));
        player->setVolume(50);
        audioProbe = new QAudioProbe();
    
        if (audioProbe->setSource(player)) {
           connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)),
                   this, SLOT(updatePlot(QAudioBuffer)));
        }
        else {
            qDebug("source not set");
        }
    }
    

    Please note that player and audioProbe are declared as pointers to QMediaPlayer and QAudioProbe, respectively, within the definition of the MainWindow class. The output always prints "source not set", but when I call
    player->play(), the file plays perfectly. Is there something I am missing? I have read the documentation quite thoroughly, and I could not find any problems with the method I employed. I have also tried this with different mp3 files and a few wav files; they all play, but the same problem occurs when trying to set the source. Thank you for your time.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Nov 2015, 22:05 last edited by
      #2

      Hi and welcome to devnet,

      Which OS are you running Qt on ?

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

      C 1 Reply Last reply 2 Nov 2015, 00:42
      0
      • S SGaist
        1 Nov 2015, 22:05

        Hi and welcome to devnet,

        Which OS are you running Qt on ?

        C Offline
        C Offline
        cweeks
        wrote on 2 Nov 2015, 00:42 last edited by
        #3

        @SGaist I am currently running Qt 5.5 on a 64-bit Windows 10 machine.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 Nov 2015, 22:05 last edited by
          #4

          IIRC, the Windows media player DirectX backend doesn't implement the QMediaAudioProbeControl but the WMF backend does

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

          V 1 Reply Last reply 3 Jun 2016, 11:33
          0
          • S SGaist
            2 Nov 2015, 22:05

            IIRC, the Windows media player DirectX backend doesn't implement the QMediaAudioProbeControl but the WMF backend does

            V Offline
            V Offline
            Violet Giraffe
            wrote on 3 Jun 2016, 11:33 last edited by
            #5

            @SGaist, how to make it work? How to switch to the required backend?
            It used to work 1 - 1.5 years ago on Windows 7 and Qt 5.2 or 5.3!

            D 1 Reply Last reply 3 Jun 2016, 11:48
            0
            • V Violet Giraffe
              3 Jun 2016, 11:33

              @SGaist, how to make it work? How to switch to the required backend?
              It used to work 1 - 1.5 years ago on Windows 7 and Qt 5.2 or 5.3!

              D Offline
              D Offline
              Devopia53
              wrote on 3 Jun 2016, 11:48 last edited by
              #6

              @Violet-Giraffe

              Please refer to the following article:

              http://lists.qt-project.org/pipermail/interest/2016-March/021221.html

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Violet Giraffe
                wrote on 3 Jun 2016, 12:05 last edited by
                #7

                I see... Had to rebuild the app with 5.5 where WMF backend was present.
                And the link doesn't seem to provide any rationale for this very odd decision. Of course, I don't care what backed is used, but I do like classes like QAudioProbe actually working.

                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