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. About QMediaPlaylist::setCurrentIndex function..
Qt 6.11 is out! See what's new in the release blog

About QMediaPlaylist::setCurrentIndex function..

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 884 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.
  • BREEZE_KOB Offline
    BREEZE_KOB Offline
    BREEZE_KO
    wrote on last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What about re-ordering the media ?

      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
      0
      • BREEZE_KOB Offline
        BREEZE_KOB Offline
        BREEZE_KO
        wrote on last edited by
        #3

        Thank you for answer.

        I keep on playback one of about 10 videos, and I'm switching to a certain video when an event occurs.
        However, I would like to solve this because the "setCurrentIndex" function changes the video during playback.

        As advised, I used the "moveMedia" function.
        However, the function returns true, but the media does not change.

         			
            QWidget* mainWidget = new QWidget(this);
            this->setCentralWidget(mainWidget);
            mainWidget->setStyleSheet("background-color: black;");
            QVBoxLayout* mainLayout = new QVBoxLayout;
            mainLayout->setMargin(0);
            mainLayout->setSpacing(0);
            mainWidget->setLayout(mainLayout);
        
            m_mediaPlayer = new QMediaPlayer;
            m_mediaPlayer->setMuted(true);
            m_playlist = new QMediaPlaylist;
        
            // current video in loop
            m_playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
            m_mediaPlayer->setPlaylist(m_playlist);
        
            QVideoWidget *videoWidget = new QVideoWidget;
            videoWidget->setAspectRatioMode(Qt::KeepAspectRatio);
            
            mainLayout->addWidget(videoWidget);
        
            m_mediaPlayer->setVideoOutput(videoWidget);
            openVideoes(DATA_PATH);
          	
            m_mediaPlayer->play();
        
        
            // in KeyEvent function
        //  m_playlist->setCurrentIndex(4);
            m_playlist->moveMedia(m_playlist->currentIndex(), 4); // 5th video in playlist
            qDebug() << m_playlist->currentMedia().canonicalUrl().fileName();
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why would it change ? From your original description, you want a specific video played after the current is done. By moving the video to the right place in the list, it’s what should happen, isn’t 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
          0

          • Login

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