mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
thumbnailers: fix build with taglib v2.0+
also added a pointer check for just in case Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
234a83d61b
commit
4094304d23
1 changed files with 21 additions and 13 deletions
|
@ -65,6 +65,7 @@ bool ATCreator::create(const QString &path, int /*w*/, int /*h*/, QImage &img)
|
||||||
if (type->is("audio/mpeg")) {
|
if (type->is("audio/mpeg")) {
|
||||||
TagLib::MPEG::File mp3File(path.toUtf8());
|
TagLib::MPEG::File mp3File(path.toUtf8());
|
||||||
TagLib::ID3v2::Tag *mp3Tag = mp3File.ID3v2Tag();
|
TagLib::ID3v2::Tag *mp3Tag = mp3File.ID3v2Tag();
|
||||||
|
|
||||||
if (mp3Tag) {
|
if (mp3Tag) {
|
||||||
TagLib::ID3v2::FrameList fList = mp3Tag->frameList("APIC");
|
TagLib::ID3v2::FrameList fList = mp3Tag->frameList("APIC");
|
||||||
TagLib::ID3v2::AttachedPictureFrame *pic = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(fList.front());
|
TagLib::ID3v2::AttachedPictureFrame *pic = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(fList.front());
|
||||||
|
@ -87,25 +88,32 @@ bool ATCreator::create(const QString &path, int /*w*/, int /*h*/, QImage &img)
|
||||||
}
|
}
|
||||||
} else if (type->is("audio/mp4")) {
|
} else if (type->is("audio/mp4")) {
|
||||||
TagLib::MP4::File mp4file(path.toUtf8());
|
TagLib::MP4::File mp4file(path.toUtf8());
|
||||||
TagLib::MP4::Tag *tag = mp4file.tag();
|
TagLib::MP4::Tag *mp4tag = mp4file.tag();
|
||||||
TagLib::MP4::ItemListMap map = tag->itemListMap();
|
|
||||||
|
|
||||||
for (TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
|
if (mp4tag) {
|
||||||
TagLib::MP4::CoverArtList coverList = (*it).second.toCoverArtList();
|
#if TAGLIB_MAJOR_VERSION >= 2
|
||||||
if (!coverList.isEmpty()) {
|
TagLib::MP4::ItemMap map = mp4tag->itemMap();
|
||||||
TagLib::MP4::CoverArt cover = coverList.front();
|
for (TagLib::MP4::ItemMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
|
||||||
TagLib::ByteVector coverData = cover.data();
|
#else
|
||||||
img.loadFromData(coverData.data(), coverData.size());
|
TagLib::MP4::ItemListMap map = mp4tag->itemListMap();
|
||||||
bRet = true;
|
for (TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
|
||||||
break;
|
#endif
|
||||||
|
TagLib::MP4::CoverArtList coverList = (*it).second.toCoverArtList();
|
||||||
|
if (!coverList.isEmpty()) {
|
||||||
|
TagLib::MP4::CoverArt cover = coverList.front();
|
||||||
|
TagLib::ByteVector coverData = cover.data();
|
||||||
|
img.loadFromData(coverData.data(), coverData.size());
|
||||||
|
bRet = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type->is("audio/x-vorbis+ogg") || type->is("audio/ogg")) {
|
} else if (type->is("audio/x-vorbis+ogg") || type->is("audio/ogg")) {
|
||||||
TagLib::Ogg::Vorbis::File file(path.toUtf8());
|
TagLib::Ogg::Vorbis::File file(path.toUtf8());
|
||||||
TagLib::Ogg::XiphComment *tag = file.tag();
|
TagLib::Ogg::XiphComment *oggtag = file.tag();
|
||||||
|
|
||||||
if (tag) {
|
if (oggtag) {
|
||||||
TagLib::List<TagLib::FLAC::Picture*> picturelist = tag->pictureList();
|
TagLib::List<TagLib::FLAC::Picture*> picturelist = oggtag->pictureList();
|
||||||
for (int i = 0; i < picturelist.size(); i++) {
|
for (int i = 0; i < picturelist.size(); i++) {
|
||||||
// qDebug() << Q_FUNC_INFO << picturelist[i]->code();
|
// qDebug() << Q_FUNC_INFO << picturelist[i]->code();
|
||||||
switch (picturelist[i]->code()) {
|
switch (picturelist[i]->code()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue