Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt MediaPlayer Playlist

Qt MediaPlayer Playlist

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 456 Views
  • 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.
  • BerkayTtkB Offline
    BerkayTtkB Offline
    BerkayTtk
    wrote on last edited by
    #1

    hello, I have a media player that I created with qt, how can I select a folder and transfer the music in it to the playlist instead of selecting the music one by one?

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

      Hi,

      Are you using Qt 6 ?

      If so, you should check the Media Player example.

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

      BerkayTtkB 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Are you using Qt 6 ?

        If so, you should check the Media Player example.

        BerkayTtkB Offline
        BerkayTtkB Offline
        BerkayTtk
        wrote on last edited by
        #3

        @SGaist no, i using qt5 and ubuntu .

        1 Reply Last reply
        0
        • NevezN Offline
          NevezN Offline
          Nevez
          wrote on last edited by
          #4

          //assume the directory exists and contains some files and you want all jpg and JPG files
          QDir directory("Pictures/MyPictures");
          QStringList images = directory.entryList(QStringList() << ".jpg" << ".JPG",QDir::Files);
          foreach(QString filename, images) {
          //do whatever you need to do
          }

          (Maybe there are better solutions, this one should work too )

          BerkayTtkB 1 Reply Last reply
          0
          • NevezN Nevez

            //assume the directory exists and contains some files and you want all jpg and JPG files
            QDir directory("Pictures/MyPictures");
            QStringList images = directory.entryList(QStringList() << ".jpg" << ".JPG",QDir::Files);
            foreach(QString filename, images) {
            //do whatever you need to do
            }

            (Maybe there are better solutions, this one should work too )

            BerkayTtkB Offline
            BerkayTtkB Offline
            BerkayTtk
            wrote on last edited by BerkayTtk
            #5

            @Nevez ,@SGaist
            Thanks for the idea, this code worked.

            QDir directory("/home/user/Music");
            QStringList filess = directory.entryList(QStringList() << ".mp3" << ".mp3",QDir::Files);
            foreach(QString filename, filess){
            QList<QStandardItem *> items;
            items.append(new QStandardItem(QDir("/home/user/Music"+filename).dirName()));
            items.append(new QStandardItem("/home/user/Music"+filename));
            m_playListModel->appendRow(items);
            m_playlist->addMedia(QMediaContent(QUrl::fromLocalFile("/home/user/Music/"+filename)));
            }

            NevezN 1 Reply Last reply
            0
            • BerkayTtkB BerkayTtk

              @Nevez ,@SGaist
              Thanks for the idea, this code worked.

              QDir directory("/home/user/Music");
              QStringList filess = directory.entryList(QStringList() << ".mp3" << ".mp3",QDir::Files);
              foreach(QString filename, filess){
              QList<QStandardItem *> items;
              items.append(new QStandardItem(QDir("/home/user/Music"+filename).dirName()));
              items.append(new QStandardItem("/home/user/Music"+filename));
              m_playListModel->appendRow(items);
              m_playlist->addMedia(QMediaContent(QUrl::fromLocalFile("/home/user/Music/"+filename)));
              }

              NevezN Offline
              NevezN Offline
              Nevez
              wrote on last edited by
              #6
              This post is deleted!
              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