diff --git a/mpd-interface/mpdconnection.cpp b/mpd-interface/mpdconnection.cpp index bf5e6866..dc80fbd2 100644 --- a/mpd-interface/mpdconnection.cpp +++ b/mpd-interface/mpdconnection.cpp @@ -1569,9 +1569,21 @@ void MPDConnection::getCover(const Song& song) QByteArray imageData; bool firstRun = true; QString path = Utils::getDir(song.file); + bool embedded = false; while (dataToRead != 0) { - Response response = sendCommand("albumart " + encodeName(path) + " " + QByteArray::number(firstRun ? 0 : (imageSize - dataToRead))); - if (!response.ok) { + Response response; + if (embedded) { + response = sendCommand("readpicture " + encodeName(song.file) + " " + QByteArray::number(firstRun ? 0 : (imageSize - dataToRead))); + } + else { + response = sendCommand("albumart " + encodeName(path) + " " + QByteArray::number(firstRun ? 0 : (imageSize - dataToRead))); + } + if (!response.ok && !embedded && supportsReadPicture()) { + DBUG << "albumart query failed; trying embedded"; + embedded = true; + continue; + } + else if (!response.ok) { DBUG << "albumart query failed"; break; } diff --git a/mpd-interface/mpdconnection.h b/mpd-interface/mpdconnection.h index bb3dbb28..b91945e6 100644 --- a/mpd-interface/mpdconnection.h +++ b/mpd-interface/mpdconnection.h @@ -292,6 +292,7 @@ class MPDConnection : public QObject { bool modifiedFindSupported() const { return ver >= CANTATA_MAKE_VERSION(0, 19, 0); } bool replaygainSupported() const { return ver >= CANTATA_MAKE_VERSION(0, 16, 0); } bool supportsCoverDownload() const { return ver >= CANTATA_MAKE_VERSION(0, 21, 0) && isMpd(); } + bool supportsReadPicture() const { return ver >= CANTATA_MAKE_VERSION(0, 22, 0) && isMpd(); } bool localFilePlaybackSupported() const; bool stickersSupported() const { return canUseStickers; }