Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to use addItem in QPlaylist

How to use addItem in QPlaylist

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 490 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davidino
    wrote on last edited by davidino
    #1

    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 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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you set a playlist on your playMusic object before using it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • D Offline
        D Offline
        davidino
        wrote on last edited by
        #3

        Hello @SGaist,
        yes, that was the problem. Inside QMusicPlayer I added:

        playlist: Playlist{id:list}
        

        and it worked.
        Thank you a lot.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved