Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QMediaPlayer doesn't play sound 6.6.3
Forum Updated to NodeBB v4.3 + New Features

QMediaPlayer doesn't play sound 6.6.3

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 4 Posters 851 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.
  • D Offline
    D Offline
    Dilabun
    wrote on last edited by
    #1

    I've tried every variation, doesn't want to play sound no matter what I do

    player = new QMediaPlayer;
    audioOutput = new QAudioOutput;
    player->setAudioOutput(new QAudioOutput);
    // ...
    player->setSource(QUrl::fromLocalFile(":/sounds/boom.mp3"));
    audioOutput->setVolume(50);
    player->play();
    
    jsulmJ JonBJ Ketan__Patel__0011K 4 Replies Last reply
    0
    • D Dilabun

      I've tried every variation, doesn't want to play sound no matter what I do

      player = new QMediaPlayer;
      audioOutput = new QAudioOutput;
      player->setAudioOutput(new QAudioOutput);
      // ...
      player->setSource(QUrl::fromLocalFile(":/sounds/boom.mp3"));
      audioOutput->setVolume(50);
      player->play();
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Dilabun How about adding error handling (https://doc.qt.io/qt-6/qmediaplayer.html#errorOccurred)?

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

      1 Reply Last reply
      0
      • D Dilabun

        I've tried every variation, doesn't want to play sound no matter what I do

        player = new QMediaPlayer;
        audioOutput = new QAudioOutput;
        player->setAudioOutput(new QAudioOutput);
        // ...
        player->setSource(QUrl::fromLocalFile(":/sounds/boom.mp3"));
        audioOutput->setVolume(50);
        player->play();
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @Dilabun
        Do you mean you have tried it with other Qt versions and it works but not with 6.6.3, or you just happen to be using 6.6.3 and it does not work?

        Have you connected the mediaStatusChanged() and errorOccurred() signals for information?

        I assume your file is a Qt resource file, right? What does qDebug() << QUrl::fromLocalFile(":/sounds/boom.mp3") show? Have you tried either qrc:/sounds/boom.mp3 or qrc:///sounds/boom.mp3? Otherwise I suggest you read through Audio not playing from .qrc resources and see whether the various proposals there resolve.

        1 Reply Last reply
        0
        • D Dilabun

          I've tried every variation, doesn't want to play sound no matter what I do

          player = new QMediaPlayer;
          audioOutput = new QAudioOutput;
          player->setAudioOutput(new QAudioOutput);
          // ...
          player->setSource(QUrl::fromLocalFile(":/sounds/boom.mp3"));
          audioOutput->setVolume(50);
          player->play();
          
          Ketan__Patel__0011K Offline
          Ketan__Patel__0011K Offline
          Ketan__Patel__0011
          wrote on last edited by Ketan__Patel__0011
          #4

          @Dilabun

          I have Question.

          Is it correct ?

          audioOutput = new QAudioOutput;
          player->setAudioOutput(new QAudioOutput); // Is it correct ?
          

          as per my knowledge it should be like this

          audioOutput = new QAudioOutput;
          player->setAudioOutput(audioOutput);
          
          1 Reply Last reply
          1
          • D Dilabun

            I've tried every variation, doesn't want to play sound no matter what I do

            player = new QMediaPlayer;
            audioOutput = new QAudioOutput;
            player->setAudioOutput(new QAudioOutput);
            // ...
            player->setSource(QUrl::fromLocalFile(":/sounds/boom.mp3"));
            audioOutput->setVolume(50);
            player->play();
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Dilabun
            I had not looked closely at your code, but what @Ketan__Patel__0011 has written is certainly correct. If that is really the code you have been trying you have created two quite separate QAudioOutputs. The one in audioOutput whose volume you set is not the one which is player's output. So start by sorting that out!

            1 Reply Last reply
            1

            • Login

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