11-13-2012 08:03 PM
I have an app where I want background music so I have toggle button to turn on/off the mp3 that plays music. However when the song ends it doesn't repeat. So I figure I need to do something with setRepeatMode or repeatMode but I can't get anything to work. Anybody have sample code with a song repeating?
Thanks
Solved! Go to Solution.
11-13-2012 09:50 PM
if you are using the MediaPlayer control, you can simply listen to the "onPlaybackCompleted" signal and restart the music:
MediaPlayer{
id: myPlayer
property bool repeatMode: true
...
onPlaybackCompleted: {
if(repeatMode)
myPlayer.play();
}
...
}
11-13-2012 10:31 PM
That is not working, cause that QML page to not load.
11-13-2012 10:40 PM - edited 11-13-2012 10:46 PM
nevermind I figured it out, it is setRepeatMode()...
MediaPlayer{
id: myPlayer
...
}
...
Button{
onClicked:{
myPlayer.setRepeatMode(1);
myPlayer.play();
}
}
02-18-2013 06:13 PM
Just to add, you should use the RepeatMode enum in your call to setRepeatMode i.e:
myPlayer.setRepeatMode(RepeatMode.Track);