This is more a question about QML but I haven’t been able to fixed. I added some music to my app and created the next component to add a fade music effect, but I haven’t been able to make it work correctly, the problem is that for some reason the NumberAnimation starts automatic when I call play() method on the audio and obviously the music stops almost immeadiate. I tryed to pause the animation on the component onCompleted event, but then the music don’t play
MyAudioComponent
Audio {
id: auRoot;
volume:1.0;
NumberAnimation on volume{
id:audiofadeout;
from:1;
to: 0;
duration:1000;
onStopped: resetAudio();
onStarted: console.log("play fadeout")
}
Component.onCompleted: audiofadeout.pause();
function isPlaying(){
if(auRoot.playbackState === Audio.PlayingState )
{
return true;
}
return false;
}
function fadeSound(){
audiofadeout.resume();
}
function resetAudio(){
auRoot.stop();
auRoot.volume=1.0;
}
}
and I used like:
Page{
MyAudioComponent {
id: auCountDown;
source: "music1.mp3"
loops: Audio.Infinite
}
onAppeared:{
auCountDown.play();
}
onDisappeared: {
auCountDown.fadeSound();
}
}
Any ideas?