Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to use addItem in QPlaylist
davidino last edited by davidino
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 null
Instead 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.
Did you set a playlist on your
playMusicobject before using it ?
davidino last edited by
yes, that was the problem. Inside QMusicPlayer I added:
and it worked.
Thank you a lot.