About QMediaPlaylist::setCurrentIndex function..
Unsolved
General and Desktop
-
Hi,
What about re-ordering the media ?
-
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();
-
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 ?