Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a QML Audio element in my app that plays a sound. When I click a button I execute:

audio.play()

and when I click it again I execute:

audio.stop()

Ideally I would like to fade the sound in a little when the user clicks the button to play the sound, and fade it out a little when they press the button to stop the sound.

How do I do this?

share|improve this question
2  
Have you tried volume? –  Goddard Aug 26 '13 at 22:04
1  
SoundEffect Element seems to have a volume property. Looping through it would do it, I think. –  hakermania Aug 26 '13 at 22:05
    
may be you can use PropertyAnimation with Audio's volume property, never tried myself though. –  Kunal Aug 27 '13 at 7:26

2 Answers 2

I don't know how to program QML, but here is something I found in the documentation

volumeCtrl.volume = Math.min(1, Math.max(0, mouse.x / (volumeBar.width - 1)));

Source : http://qt-project.org/doc/qt-5.0/qtmultimedia/multimedia-audioengine-qml-audioengine-qml.html

share|improve this answer

Use a number or property animation.

NumberAnimation{ id:audiofadeout; target: audioFile; property: "volume"; from:1; to: 0; duration:1000 }

Then execute w/

audiofadeout.start()



share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.