diff --git a/icons/audio-volume-high.png b/icons/audio-volume-high.png index 6e41d23..01cc03d 100644 Binary files a/icons/audio-volume-high.png and b/icons/audio-volume-high.png differ diff --git a/icons/audio-volume-muted.png b/icons/audio-volume-muted.png index 213f57a..610fde7 100644 Binary files a/icons/audio-volume-muted.png and b/icons/audio-volume-muted.png differ diff --git a/icons/media-album-cover.svg b/icons/media-album-cover.svg new file mode 100644 index 0000000..6ca3b42 --- /dev/null +++ b/icons/media-album-cover.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/icons/media-playback-pause.png b/icons/media-playback-pause.png index bd1dfd0..0d8b98c 100644 Binary files a/icons/media-playback-pause.png and b/icons/media-playback-pause.png differ diff --git a/icons/media-playback-start.png b/icons/media-playback-start.png index d711d9b..86e30e7 100644 Binary files a/icons/media-playback-start.png and b/icons/media-playback-start.png differ diff --git a/icons/media-playback-stop.png b/icons/media-playback-stop.png index f388a75..d96584c 100644 Binary files a/icons/media-playback-stop.png and b/icons/media-playback-stop.png differ diff --git a/icons/media-playlist-normal.png b/icons/media-playlist-normal.png new file mode 100644 index 0000000..8af9e29 Binary files /dev/null and b/icons/media-playlist-normal.png differ diff --git a/icons/media-playlist-repeat-song.png b/icons/media-playlist-repeat-song.png new file mode 100644 index 0000000..219de4e Binary files /dev/null and b/icons/media-playlist-repeat-song.png differ diff --git a/icons/media-playlist-repeat.png b/icons/media-playlist-repeat.png index b563a40..fd4830d 100644 Binary files a/icons/media-playlist-repeat.png and b/icons/media-playlist-repeat.png differ diff --git a/icons/media-playlist-shuffle.png b/icons/media-playlist-shuffle.png new file mode 100644 index 0000000..d003ef6 Binary files /dev/null and b/icons/media-playlist-shuffle.png differ diff --git a/icons/media-skip-backward.png b/icons/media-skip-backward.png index ac6b8fa..a2aa0df 100644 Binary files a/icons/media-skip-backward.png and b/icons/media-skip-backward.png differ diff --git a/icons/media-skip-forward.png b/icons/media-skip-forward.png index ffc9c92..fd0a4c5 100644 Binary files a/icons/media-skip-forward.png and b/icons/media-skip-forward.png differ diff --git a/icons/view-media-playlist.png b/icons/view-media-playlist.png index 66c4438..d4c4212 100644 Binary files a/icons/view-media-playlist.png and b/icons/view-media-playlist.png differ diff --git a/icons/window-close.png b/icons/window-close.png index 1085efa..0e4afef 100644 Binary files a/icons/window-close.png and b/icons/window-close.png differ diff --git a/icons/window-minimize.png b/icons/window-minimize.png index 38c741e..debec73 100644 Binary files a/icons/window-minimize.png and b/icons/window-minimize.png differ diff --git a/mainwindow.cpp b/mainwindow.cpp index be5af93..e7c557e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -172,8 +172,11 @@ void MainWindow::loadFile() */ QMediaPlaylist *MainWindow::createPlaylist(QList urlList) { + if (m_mediaPlayer->playlist()) { + m_mediaPlayer->playlist()->disconnect(); + } + QMediaPlaylist * playlist = new QMediaPlaylist(m_mediaPlayer); - playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); for (const QUrl & url : urlList) { bool succ = playlist->addMedia(QMediaContent(url)); @@ -182,6 +185,26 @@ QMediaPlaylist *MainWindow::createPlaylist(QList urlList) } } + connect(playlist, &QMediaPlaylist::playbackModeChanged, this, [=](QMediaPlaylist::PlaybackMode mode) { + switch (mode) { + case QMediaPlaylist::CurrentItemInLoop: + ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-playlist-repeat-song.png")); + break; + case QMediaPlaylist::Loop: + ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-playlist-repeat.png")); + break; + case QMediaPlaylist::Sequential: + ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-playlist-normal.png")); + break; + case QMediaPlaylist::Random: + ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-playlist-shuffle.png")); + break; + default: + break; + } + }); + + playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); m_mediaPlayer->setPlaylist(playlist); m_playlistModel->setPlaylist(playlist); @@ -379,6 +402,29 @@ void MainWindow::initConnections() default: break; } - qDebug(m_mediaPlayer->errorString().toUtf8() + "aaaaaaaaaaaaa"); + qDebug("%s aaaaaaaaaaaaa", m_mediaPlayer->errorString().toUtf8().data()); }); } + +void MainWindow::on_playbackModeBtn_clicked() +{ + QMediaPlaylist * playlist = m_mediaPlayer->playlist(); + if (!playlist) return; + + switch (playlist->playbackMode()) { + case QMediaPlaylist::CurrentItemInLoop: + playlist->setPlaybackMode(QMediaPlaylist::Loop); + break; + case QMediaPlaylist::Loop: + playlist->setPlaybackMode(QMediaPlaylist::Sequential); + break; + case QMediaPlaylist::Sequential: + playlist->setPlaybackMode(QMediaPlaylist::Random); + break; + case QMediaPlaylist::Random: + playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); + break; + default: + break; + } +} diff --git a/mainwindow.h b/mainwindow.h index cfe6b10..4bb41ff 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -36,6 +36,9 @@ protected: void centerWindow(); QMediaPlaylist *createPlaylist(QList urlList); +private slots: + void on_playbackModeBtn_clicked(); + private slots: void on_closeWindowBtn_clicked(); void on_playBtn_clicked(); diff --git a/mainwindow.ui b/mainwindow.ui index 8bd141a..d8ceb04 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -186,7 +186,10 @@ QLabel#coverLabel { - AlbumCover + + + + :/icons/icons/media-album-cover.svg true @@ -505,7 +508,7 @@ QLabel#coverLabel { - :/icons/icons/media-playlist-repeat.png:/icons/icons/media-playlist-repeat.png + :/icons/icons/media-playlist-repeat-song.png:/icons/icons/media-playlist-repeat-song.png diff --git a/resources.qrc b/resources.qrc index c34920d..34086bf 100644 --- a/resources.qrc +++ b/resources.qrc @@ -12,5 +12,9 @@ icons/media-playback-pause.png icons/audio-volume-muted.png icons/app-icon.svg + icons/media-playlist-shuffle.png + icons/media-playlist-repeat-song.png + icons/media-playlist-normal.png + icons/media-album-cover.svg