Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QML Audio element plays audio just once

    QML and Qt Quick
    2
    4
    880
    Loading More Posts
    • 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.
    • M
      m_andrej last edited by m_andrej

      In the following example the sound is played only when I click Play button for the first time. Subsequent clicks have no effect. Anybody knows why?

      import QtQuick 2.5
      import QtQuick.Window 2.2
      import QtQuick.Controls 1.4
      import QtMultimedia 5.5
      
      Window {
          visible: true
      
          Column {
              anchors.centerIn: parent
              Button {
                  text: "Play"
                  onClicked:
                      audio.play()
              }
              Button {
                  text: "Stop"
                  onClicked:
                      audio.stop()
              }
          }
          Audio {
              id: audio
              source: "success.ogg"
              onErrorChanged: {
                  console.log("error: " + error)
              }
              onStatusChanged:
                  console.log("status: " + status)
          }
      }
      

      I already tried:

      • to set loops property to 3, but the media is still played just once
      • MediaPlayer instead of Audio element, that still didn't help
      • to click Stop button after the music finishes and then again Play

      I'm on Ubuntu Desktop, running Qt 5.5, gcc, 64-bit.

      1 Reply Last reply Reply Quote 0
      • X
        xargs1 last edited by

        Have you tried SoundEffect? I've used that successfully on Linux.

        1 Reply Last reply Reply Quote 1
        • M
          m_andrej last edited by m_andrej

          SoundEffect works, although Audio would be more appropriate because it can hadle compressed formats.

          I made a bug report from this: https://bugreports.qt.io/browse/QTBUG-51204

          1 Reply Last reply Reply Quote 0
          • M
            m_andrej last edited by

            xargs1:
            I realized that using SoundEffect crashes my app randomly.
            I get the following output:
            "Assertion 'o' failed at pulse/operation.c:67, function pa_operation_unref(). Aborting."

            Is there any fix to that?

            1 Reply Last reply Reply Quote 0
            • First post
              Last post