QML Audio element plays audio just once



  • 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.



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



  • 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



  • 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?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.