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. QSoundEffect(pulseaudio): Error decoding source
Forum Updated to NodeBB v4.3 + New Features

QSoundEffect(pulseaudio): Error decoding source

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 2.4k Views 3 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.
  • E Offline
    E Offline
    Evgeny Siberia
    wrote on 19 May 2021, 17:09 last edited by
    #1

    Hi. Why sound doesn't play?
    I tried use mp3 from recources, but it didn't help. What am I doing wrong?
    The click.mp3 located the same folder's level as MainWindow.

    QT       += core gui
    QT       += multimedia
    
    void MainWindow::on_pushButton_clicked()
    {
        QSound::play("./click.mp3");
    }
    

    if you see mistakes in English tell me about it

    M 1 Reply Last reply 19 May 2021, 17:30
    0
    • E Evgeny Siberia
      19 May 2021, 17:09

      Hi. Why sound doesn't play?
      I tried use mp3 from recources, but it didn't help. What am I doing wrong?
      The click.mp3 located the same folder's level as MainWindow.

      QT       += core gui
      QT       += multimedia
      
      void MainWindow::on_pushButton_clicked()
      {
          QSound::play("./click.mp3");
      }
      
      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 19 May 2021, 17:30 last edited by mrjj
      #2

      @Evgeny-Siberia

      Hi
      well you ask it to load it from the current folder which would be the build folder
      once the app runs. ( not the project folder)
      try to put it there.

      Also Im not sure QSound does support mp3 files. all samples i saw always use *.wav.

      1 Reply Last reply
      2
      • E Offline
        E Offline
        Evgeny Siberia
        wrote on 19 May 2021, 17:58 last edited by Evgeny Siberia
        #3

        @mrjj
        I converted to wav, but it didn't help.

        if you see mistakes in English tell me about it

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 19 May 2021, 17:59 last edited by
          #4

          Hi,

          As @mrjj you should also copy the file in your build folder since you are using a relative path.

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

          E 1 Reply Last reply 19 May 2021, 18:10
          2
          • S SGaist
            19 May 2021, 17:59

            Hi,

            As @mrjj you should also copy the file in your build folder since you are using a relative path.

            E Offline
            E Offline
            Evgeny Siberia
            wrote on 19 May 2021, 18:10 last edited by
            #5

            @SGaist
            @mrjj
            Thank you!
            It helped, but why It doesn't work from recources?

            if you see mistakes in English tell me about it

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 19 May 2021, 18:14 last edited by
              #6

              Your path is not a resource path.

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

              E 1 Reply Last reply 19 May 2021, 18:19
              1
              • S SGaist
                19 May 2021, 18:14

                Your path is not a resource path.

                E Offline
                E Offline
                Evgeny Siberia
                wrote on 19 May 2021, 18:19 last edited by Evgeny Siberia
                #7

                @SGaist
                Shurely, I changed code. And I copied path (right click on the recource file in Qt -> copy path)

                QSound *s = new QSound(":/main/click.wav");
                s->play();
                

                Updated: all are working, my wrong, thank you.

                if you see mistakes in English tell me about it

                1 Reply Last reply
                1

                1/7

                19 May 2021, 17:09

                • Login

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