[SailfishDevel] Problem with playing sounds in first application

Luis Manuel Ramos Da Costa aliasbody at gmail.com
Tue Feb 3 23:13:44 UTC 2015


Hello Everyone,

I've started developing for Jolla today, I am quite familiarez with the
Qt/C++ language but not enough with the QML part.

I am trying to create a simple (and quite stupid) application which would
simply play a Whip sound by clicking on the icon and whiping the phone.
Maybe in later versions I would make it more... well.. usefull but until
that day I am just trying to learn.

So here is my code right now :
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.0

ApplicationWindow
{
    MouseArea {
        width   : parent.width
        height  : parent.height

        Image {
            id                      : whipImg;
            source                  :
"qrc:/img/resources/images/whipImg.png"
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter  : parent.verticalCenter
        }

        onClicked : {
            whipSound.stop()
            whipSound.play()
        }

        Audio {
            id      : whipSound
            loops   : Audio.Infinite
            source:"qrc:/sounds/resources/sounds/whipSound.flac"
        }
    }
}

And I have a problem with this. The song plays one time by taping on the
picture (the song is a .flac file with 1second long of audio), and after
that if I press the picture again it simply doesn't play.

How can I solve this problem ?

Best Regards Everyone !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20150203/4db02644/attachment.html>


More information about the Devel mailing list