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. Can't Hear the sound when using QMediaPlayer

Can't Hear the sound when using QMediaPlayer

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 4.5k Views 1 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.
  • P Offline
    P Offline
    Project try
    wrote on last edited by
    #1

    Hey , first of all I'm sorry for asking this even though there're solution out there , but I can't understand the solution , I built Qt statically like months ago and when I tried to use QMediaPlayer I can't hear any sound , it gives me this note:

    @defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer" @

    @
    bool MainWindow::PlaySong(const QString& filePath)
    {
    if(filePath.isEmpty())
    return false;

    qDebug()<<"path to song is "<<filePath;
    QMediaPlayer* player = new QMediaPlayer;
    player->setMedia(QUrl("mpthreetest.mp3"));
    
    player->play();
    return true;
    

    }
    @

    the file path wasn't working so I copied the same exact mp3 file to the project folder to check but still it isn't working.

    I'm using Windows 8 64bit.

    if the only solution is to build the whole library again , please direct me to audio libraries that can play any sound extension.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Project try
      wrote on last edited by
      #2

      Well I downloaded the last version of Qt but still the same problem.

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

        Hi,

        Are you sure you built the QtMultimedia backend properly and that you are linking to it ?

        Also note that you have there a memory leak there since every time your call PlaySong you create a new QMediaPlayer.

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

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Project try
          wrote on last edited by
          #4

          [quote author="SGaist" date="1415318159"]Hi,

          Are you sure you built the QtMultimedia backend properly and that you are linking to it ?

          Also note that you have there a memory leak there since every time your call PlaySong you create a new QMediaPlayer.

          [/quote]

          Hey, when I built Qt statically about 5-8 months ago I followed a post and it worked , but I think there was a library that I had to build myself I think it's QNetwork ? i'm not really sure , but as I said I downloaded the last version which is 5.3.2 and it still doesn't work.

          about the linking part I'm not sure if I understand you , but I did this in the pro file:

          @QT += multimedia@

          About the memory leak I'm not really planning on doing this but I just had to test it "I'll be using the pointer to mediaplayer as a memeber variable in my class so I can link it to signals and slots" , also I thought when you give a parent to a class that uses subclasses of QObject then it would automatically take care of the deletion process for you.

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

            You don't give any parent to player so nothing will be done. If you set a parent, indeed it will be deleted at the end of its parent life. However it generally means at the end of the application.

            I have some memories about the need for the QtMultimedia plugins to be dynamic however, I don't' know if it still applies.

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

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Project try
              wrote on last edited by
              #6

              [quote author="SGaist" date="1415406195"]You don't give any parent to player so nothing will be done. If you set a parent, indeed it will be deleted at the end of its parent life. However it generally means at the end of the application.

              I have some memories about the need for the QtMultimedia plugins to be dynamic however, I don't' know if it still applies.[/quote]

              Well , I downloaded The newest version of Qt but it still doesn't work , is there an alternative ?

              My idea is simple , I'll make a simple playlist that plays audio only and when he clicks on a song it automatically plays like any audio player out there , where there's a progress bar , pausing , stopping , starting and repeating among other simple things like speeding the audio and stuff.

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

                Did you check that you don't have any error with QMediaPlayer ?

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

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Project try
                  wrote on last edited by
                  #8

                  [quote author="SGaist" date="1415487310"]Did you check that you don't have any error with QMediaPlayer ?[/quote]

                  How can I check that ? All I did is write that code in my post and when I call that function it gives me the same thing in the application output it says no service found for mediaplayer.

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

                    Can you try with a dynamic build of Qt ?

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

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      Project try
                      wrote on last edited by
                      #10

                      [quote author="SGaist" date="1415575656"]Can you try with a dynamic build of Qt ?[/quote]

                      Well, isn't the downloadable version of Qt is dynamic ? I downloaded the newest but opened my old project to test it , should I start a new project or what ?

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

                        Which version you where using wasn't clear.

                        Anyway, run your application with QT_DEBUG_PLUGINS=1 That should help find the misbehaving part

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - 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