Solved How to use addItem in QPlaylist
-
Hello,
I'm trying to make an mp3 player and I think that the most convenient way to choose the replay mode (loop, currentItemPlay, etc.) is through playlist.
So far I've used MediaPlayer and changing its source property according to the selected song. Now I'd like to use playlist and add items as follow:playMusic.playlist.addItem(Qt.resolvedUrl(folderModel.get(index,"fileURL"))); or playMusic.playlist.addItem(folderModel.get(index,"fileURL"));
Unfortunately I always get the error:
TypeError: Cannot call method 'addItem' of nullInstead if I use my usual method changing source property t works.
Anyone has got experience about it? I didn't find many posts that deal it.
Thank you -
Hi,
Did you set a playlist on your
playMusic
object before using it ? -
Hello @SGaist,
yes, that was the problem. Inside QMusicPlayer I added:playlist: Playlist{id:list}
and it worked.
Thank you a lot.