Improved embedded cover handling for Ogg METADATA_BLOCK_PICTURE

This commit is contained in:
Martin Brodbeck 2013-12-11 12:28:02 +01:00 committed by John Maguire
parent 3ed34076c8
commit 587fa39dad
1 changed files with 9 additions and 2 deletions

View File

@ -792,9 +792,16 @@ QByteArray TagReader::LoadEmbeddedArt(const QString& filename) const {
// Other than the below mentioned non-standard COVERART, METADATA_BLOCK_PICTURE
// is the proposed tag for cover pictures.
// (see http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE)
// TODO: Take into account that there might be multiple picture tags, look for
// front cover, ...
if (map.contains("METADATA_BLOCK_PICTURE")) {
TagLib::StringList pict_list = map["METADATA_BLOCK_PICTURE"];
for(std::list<TagLib::String>::iterator it = pict_list.begin(); it != pict_list.end(); ++it) {
QByteArray data(QByteArray::fromBase64(it->toCString()));
TagLib::ByteVector tdata(data.data(), data.size());
TagLib::FLAC::Picture p(tdata);
if (p.type() == TagLib::FLAC::Picture::FrontCover)
return QByteArray(p.data().data(), p.data().size());
}
// If there was no specific front cover, just take the first picture
QByteArray data(QByteArray::fromBase64(map["METADATA_BLOCK_PICTURE"].front().toCString()));
TagLib::ByteVector tdata(data.data(), data.size());
TagLib::FLAC::Picture p(tdata);