feat: switch playback mode, and add a default album cover
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 766 B |
111
icons/media-album-cover.svg
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="512"
|
||||||
|
height="512"
|
||||||
|
viewBox="0 0 135.46667 135.46667"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
sodipodi:docname="新建文档 1.2020_04_10_18_17_14.0.svg"
|
||||||
|
inkscape:version="0.92.4 5da689c313, 2019-01-14">
|
||||||
|
<defs
|
||||||
|
id="defs2">
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
id="linearGradient4537">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop4533" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop4535" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient4537"
|
||||||
|
id="linearGradient4539"
|
||||||
|
x1="0.40317535"
|
||||||
|
y1="229.43675"
|
||||||
|
x2="135.1013"
|
||||||
|
y2="229.43675"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.98994949"
|
||||||
|
inkscape:cx="275.73058"
|
||||||
|
inkscape:cy="224.36371"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
units="px"
|
||||||
|
inkscape:pagecheckerboard="true"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1009"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid23" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-161.53332)">
|
||||||
|
<ellipse
|
||||||
|
id="path21"
|
||||||
|
cx="67.73333"
|
||||||
|
cy="229.26665"
|
||||||
|
style="fill:none;stroke:#dcdcdc;stroke-width:10.78703594;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.627451;image-rendering:auto"
|
||||||
|
rx="62.339813"
|
||||||
|
ry="62.339817" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="star"
|
||||||
|
style="fill:none;stroke:#dcdcdc;stroke-width:10.58333302;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.627451"
|
||||||
|
id="path822"
|
||||||
|
sodipodi:sides="3"
|
||||||
|
sodipodi:cx="13.418155"
|
||||||
|
sodipodi:cy="232.93301"
|
||||||
|
sodipodi:r1="35.114174"
|
||||||
|
sodipodi:r2="17.557087"
|
||||||
|
sodipodi:arg1="0.93052449"
|
||||||
|
sodipodi:arg2="1.977722"
|
||||||
|
inkscape:flatsided="true"
|
||||||
|
inkscape:rounded="0"
|
||||||
|
inkscape:randomized="0"
|
||||||
|
d="M 34.395835,261.09224 -21.457293,237.0206 27.315922,200.6862 Z"
|
||||||
|
inkscape:transform-center-x="-13.511421"
|
||||||
|
inkscape:transform-center-y="5.3318399"
|
||||||
|
transform="matrix(0.42950169,0.83812005,-0.98835371,0.36421574,287.49969,132.9204)" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 812 B |
Before Width: | Height: | Size: 428 B After Width: | Height: | Size: 428 B |
BIN
icons/media-playlist-normal.png
Normal file
After Width: | Height: | Size: 606 B |
BIN
icons/media-playlist-repeat-song.png
Normal file
After Width: | Height: | Size: 809 B |
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 802 B |
BIN
icons/media-playlist-shuffle.png
Normal file
After Width: | Height: | Size: 825 B |
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 553 B |
Before Width: | Height: | Size: 549 B After Width: | Height: | Size: 549 B |
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 391 B |
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
|
@ -172,8 +172,11 @@ void MainWindow::loadFile()
|
||||||
*/
|
*/
|
||||||
QMediaPlaylist *MainWindow::createPlaylist(QList<QUrl> urlList)
|
QMediaPlaylist *MainWindow::createPlaylist(QList<QUrl> urlList)
|
||||||
{
|
{
|
||||||
|
if (m_mediaPlayer->playlist()) {
|
||||||
|
m_mediaPlayer->playlist()->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
QMediaPlaylist * playlist = new QMediaPlaylist(m_mediaPlayer);
|
QMediaPlaylist * playlist = new QMediaPlaylist(m_mediaPlayer);
|
||||||
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
|
|
||||||
|
|
||||||
for (const QUrl & url : urlList) {
|
for (const QUrl & url : urlList) {
|
||||||
bool succ = playlist->addMedia(QMediaContent(url));
|
bool succ = playlist->addMedia(QMediaContent(url));
|
||||||
|
@ -182,6 +185,26 @@ QMediaPlaylist *MainWindow::createPlaylist(QList<QUrl> 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_mediaPlayer->setPlaylist(playlist);
|
||||||
m_playlistModel->setPlaylist(playlist);
|
m_playlistModel->setPlaylist(playlist);
|
||||||
|
|
||||||
|
@ -379,6 +402,29 @@ void MainWindow::initConnections()
|
||||||
default:
|
default:
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,9 @@ protected:
|
||||||
void centerWindow();
|
void centerWindow();
|
||||||
QMediaPlaylist *createPlaylist(QList<QUrl> urlList);
|
QMediaPlaylist *createPlaylist(QList<QUrl> urlList);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_playbackModeBtn_clicked();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_closeWindowBtn_clicked();
|
void on_closeWindowBtn_clicked();
|
||||||
void on_playBtn_clicked();
|
void on_playBtn_clicked();
|
||||||
|
|
|
@ -186,7 +186,10 @@ QLabel#coverLabel {
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>AlbumCover</string>
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="resources.qrc">:/icons/icons/media-album-cover.svg</pixmap>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -505,7 +508,7 @@ QLabel#coverLabel {
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources.qrc">
|
<iconset resource="resources.qrc">
|
||||||
<normaloff>:/icons/icons/media-playlist-repeat.png</normaloff>:/icons/icons/media-playlist-repeat.png</iconset>
|
<normaloff>:/icons/icons/media-playlist-repeat-song.png</normaloff>:/icons/icons/media-playlist-repeat-song.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
|
|
@ -12,5 +12,9 @@
|
||||||
<file>icons/media-playback-pause.png</file>
|
<file>icons/media-playback-pause.png</file>
|
||||||
<file>icons/audio-volume-muted.png</file>
|
<file>icons/audio-volume-muted.png</file>
|
||||||
<file>icons/app-icon.svg</file>
|
<file>icons/app-icon.svg</file>
|
||||||
|
<file>icons/media-playlist-shuffle.png</file>
|
||||||
|
<file>icons/media-playlist-repeat-song.png</file>
|
||||||
|
<file>icons/media-playlist-normal.png</file>
|
||||||
|
<file>icons/media-album-cover.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|