Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] enum QMediaPlaylist::PlaybackMode does not work properly



  • Hello, I am trying to make an option for playlist to random choose songs...

    It works if I put it into main function...
    @MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow), ignoreSliderChanges(false)
    {
    ui->setupUi(this);

    playlist->setPlaybackMode(QMediaPlaylist::Loop);

    }@

    But it does not work if I place it in any other function (code below)... It show text in label but does not change playing state...
    @
    void testApp::playRandom()
    if (ui->pushButton->isChecked())
    {
    playlist->setPlaybackMode(QMediaPlaylist::Loop);
    ui->label->setText("Loop");
    }
    else
    {
    playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
    ui->label->setText("Once");
    }

    }@

    Is this a bug or I am doing something wrong???

    Thanks in advance...



  • Ahhh... I forgot to add ::PlaybackMode... Works now...

    @if (ui->pushButton->isChecked())
    {
    playlist->setPlaybackMode(QMediaPlaylist::PlaybackMode::Random);
    }
    else
    {
    playlist->setPlaybackMode(QMediaPlaylist::PlaybackMode::Loop);
    }
    @


Log in to reply