Qt World Summit: Submit your Presentation

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:


    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.
    Thank you

  • Lifetime Qt Champion


    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.

Log in to reply