Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Audio element plays audio just once

QML Audio element plays audio just once

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.3k Views 2 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.
  • M Offline
    M Offline
    m_andrej
    wrote on last edited by m_andrej
    #1

    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
    0
    • X Offline
      X Offline
      xargs1
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • M Offline
        M Offline
        m_andrej
        wrote on last edited by m_andrej
        #3

        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
        0
        • M Offline
          M Offline
          m_andrej
          wrote on last edited by
          #4

          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
          0

          • Login

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