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.
  • Evgeny SiberiaE Offline
    Evgeny SiberiaE Offline
    Evgeny Siberia
    wrote on 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

    mrjjM 1 Reply Last reply
    0
    • Evgeny SiberiaE Evgeny Siberia

      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");
      }
      
      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      • Evgeny SiberiaE Offline
        Evgeny SiberiaE Offline
        Evgeny Siberia
        wrote on 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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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

          Evgeny SiberiaE 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

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

            Evgeny SiberiaE Offline
            Evgeny SiberiaE Offline
            Evgeny Siberia
            wrote on 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
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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

              Evgeny SiberiaE 1 Reply Last reply
              1
              • SGaistS SGaist

                Your path is not a resource path.

                Evgeny SiberiaE Offline
                Evgeny SiberiaE Offline
                Evgeny Siberia
                wrote on 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

                • Login

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