From 099284d5d40fc5ad21bcb7bd8b65dce4c4fc0daa Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 10 Apr 2020 18:35:29 +0800 Subject: [PATCH] feat: switch playback mode, and add a default album cover --- icons/audio-volume-high.png | Bin 1228 -> 1228 bytes icons/audio-volume-muted.png | Bin 766 -> 766 bytes icons/media-album-cover.svg | 111 +++++++++++++++++++++++++++ icons/media-playback-pause.png | Bin 541 -> 541 bytes icons/media-playback-start.png | Bin 812 -> 812 bytes icons/media-playback-stop.png | Bin 428 -> 428 bytes icons/media-playlist-normal.png | Bin 0 -> 606 bytes icons/media-playlist-repeat-song.png | Bin 0 -> 809 bytes icons/media-playlist-repeat.png | Bin 809 -> 802 bytes icons/media-playlist-shuffle.png | Bin 0 -> 825 bytes icons/media-skip-backward.png | Bin 553 -> 553 bytes icons/media-skip-forward.png | Bin 549 -> 549 bytes icons/view-media-playlist.png | Bin 391 -> 391 bytes icons/window-close.png | Bin 494 -> 494 bytes icons/window-minimize.png | Bin 318 -> 318 bytes mainwindow.cpp | 50 +++++++++++- mainwindow.h | 3 + mainwindow.ui | 7 +- resources.qrc | 4 + 19 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 icons/media-album-cover.svg create mode 100644 icons/media-playlist-normal.png create mode 100644 icons/media-playlist-repeat-song.png create mode 100644 icons/media-playlist-shuffle.png diff --git a/icons/audio-volume-high.png b/icons/audio-volume-high.png index 6e41d23f7b32ea5269f1d276ce13049da295d57f..01cc03da292fc18fc18a7f9e9ace7fe305a5b5c4 100644 GIT binary patch delta 71 zcmX@Zd4_XBHwPDoxaK6eAD1>xe$6asY-M6>Wn`#rU|?lnAXRPscyd3Bf-H(?wpw#M P0}yz+`njxgN@xNA9A*@R delta 71 zcmX@Zd4_XBHwQbjwy440Q`0t1e$6asWMyb+WoWK#U|?ln;B)+q$>e?(1z8kP+gTwU P3_#%N>gTe~DWM4fDGU`I diff --git a/icons/audio-volume-muted.png b/icons/audio-volume-muted.png index 213f57af893e393e293e03ee919082e5ae344c75..610fde72869a26fec5f6f065d39507836988958b 100644 GIT binary patch delta 71 zcmeyz`j2%&HwPDoxaK6eAD1>xmSqw&wlXocGBVUQFt9Q(kgB$RJozA#f-H(?wpw#M P0}yz+`njxgN@xNA5FZpl delta 71 zcmeyz`j2%&HwQbjwy440Q`0t1mSqw&vNE)^GBnpVFt9Q(@Hzg*Wb#2K1z8kP+gTwU P3_#%N>gTe~DWM4f9K{sc 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 bd1dfd0dabdc79714b10c57571d34cc45f2c64cb..0d8b98c01c2a79f8b573c052db3d0bcf301cbf60 100644 GIT binary patch delta 71 zcmbQsGM8mSHwPDoxaK6eAD1>xwqX=BwlXocGBVUQFt9Q(kgB$RJoy2mf-H(?wpw#M P0}yz+`njxgN@xNA1z8kP+gTwU P3_#%N>gTe~DWM4f@l+I2 diff --git a/icons/media-playback-start.png b/icons/media-playback-start.png index d711d9b64077cf04f628bf2d717874955721ff33..86e30e78640b19090aa698d878fc7cf2ce3a2f07 100644 GIT binary patch delta 71 zcmZ3(wuWs&HwPDoxaK6eAD1>x_GS_^wlXocGBVUQFt9Q(kgB$RJo!D7f-H(?wpw#M P0}yz+`njxgN@xNA^JEkI delta 71 zcmZ3(wuWs&HwQbjwy440Q`0t1_GS_^vNE)^GBnpVFt9Q(@Hzg*Wb%6^1z8kP+gTwU P3_#%N>gTe~DWM4f02vgN diff --git a/icons/media-playback-stop.png b/icons/media-playback-stop.png index f388a757c34a729f9eb3a38dc7b3313920cd192b..d96584cbb7cbfe79791d5be0f3b4031aee3663a6 100644 GIT binary patch delta 70 zcmZ3(yoPx~HwPDoxaK6eAD1RhJ}qc$Wnye)WT=d#Wzp$P!`S`=#l diff --git a/icons/media-playlist-normal.png b/icons/media-playlist-normal.png new file mode 100644 index 0000000000000000000000000000000000000000..8af9e293d5ca9dd290ba45a2dc538364b9ae53f1 GIT binary patch literal 606 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^+km7#f-x7=Hc-(k~epN(~qoUL`OvSj}Ky5YL|!f7A`AmMO{G-G$+Qd;gjJKptm- zM`SSr1Gg{;GcwGYBLNg-FY)wsWq-oL#UZXaN$$rb1_s7JPZ!4!kK=Er?)P>|6lt4( zUcO{K>+~HvV|bOmtDOwZSYy9H^TblcqKzF*99h{N%U<+roM>wc>1Yzj;?yy?xbk&T ztVpR={$bTiO7GJ3c<24J=D%Ng{&!K!*@UN(8|pcJh%?AHOsHMGFktylW`&z_M;#V+ zdA`(V;8osfW4UkU+dB^y{*V=LDW0n$z^RtJs{Z!%6OW(nlon9&I`LO{tJ<1#elI<@ zE_$^5z;AU0pBE)}U$1()h0j2qQ-A4}I~-iBQ8#V~q+frx`pmUcmYk1ztn6MS?EgA7 zTe)CM!Gr@2(g!@494w?N1nfM`EkkqPr~B!x2r6eNJ+paHPlvJ9fn?pO=VF5&buQb$ zsJQdk+@pIfcj&BNs$Chk>w3mVhm%)5Hg+0X?7P1!>&eP5Qk*(E)63?T-L%?s`$S1z z<=;)4jGKD${APrlxo2>axvq1w#JyHUh93-zw0exQnX8Tf!&|k)HKHUXu_Vk4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^+km7#f-x7=Hc-(k~epN(~qoUL`OvSj}Ky5YL|!f7A`AmMO{G-G$+Qd;gjJKptm- zM`SSr1Gg{;GcwGYBLNg-FY)wsWq-oL#UZXaN$$rbpe7kl7sn8f<9DapX9x$%9Jep` zd@;2pjwwm+I**rc$>d3^nwMB~{6F9*utZ@Oho4^4xtBSGMS|1)7B!az3Cvx^C%QC* z-SDc`w#v?_PH}5LCe5C6I5w(y=dmraTy@*O*S)W;*#G|fUF)N1*+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(kgB$RJoycyf-H(?wpw#M P0}yz+`njxgN@xNA?@|-# delta 71 zcmZ3gTe~DWM4f`}h=s diff --git a/icons/media-skip-forward.png b/icons/media-skip-forward.png index ffc9c9281d4be1c0702bda4f7c2264a1c83626ad..fd0a4c507e8be4ae4fb2c701c42e241f18f36095 100644 GIT binary patch delta 71 zcmZ3=vXo^)HwPDoxaK6eAD1>xc3~7WwlXocGBVUQFt9Q(kgB$RJoyEqf-H(?wpw#M P0}yz+`njxgN@xNA>&6q= delta 71 zcmZ3=vXo^)HwQbjwy440Q`0t1c3~7WvNE)^GBnpVFt9Q(@Hzg*Wbz9}1z8kP+gTwU P3_#%N>gTe~DWM4f_-qt% diff --git a/icons/view-media-playlist.png b/icons/view-media-playlist.png index 66c44381e19c8beb23ab3b65e1b87c0b84e53c79..d4c4212bd8c1d088e42d66ba0fabd698b853dccd 100644 GIT binary patch delta 70 zcmZo?ZfBm*&B4VXt~p8W$EAsrmkAnMnHXCc8EP9CSQ!{dRa-xv?8T@ciz1q>)*R0O N1fH&bF6*2UngGoo6FvX{ delta 70 zcmZo?ZfBm*&B4yBEo!j$)U=6{mkAnK8CqHynrj;vSQ!}j9Didn*^5y@7Dd!{R!9c} O5O})!xvXx=4BK#wlXocGBVUQFt9Q(kgB$RJb5Fdf-H(?wpw#M P0}yz+`njxgN@xNA0EQF$ delta 71 zcmaFI{Em4-HwQbjwy440Q`0t1=4BK#vNE)^GBnpVFt9Q(@Hzg*Wb#Hv1z8kP+gTwU P3_#%N>gTe~DWM4f4J;It diff --git a/icons/window-minimize.png b/icons/window-minimize.png index 38c741e5ae146cda2cc0dda84d40b78d94bad1b1..debec732e8c93e7fec2545b562cacbaaece33881 100644 GIT binary patch delta 70 zcmdnTw2x^*HwPDoxaK6eAD1RhjukYvGBLI?GSoIOure@^s 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