mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
thumbnailers: OGG audio thumbnail fix
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7a8dcdeb39
commit
1fe47783e1
1 changed files with 23 additions and 59 deletions
|
@ -68,40 +68,33 @@ bool ATCreator::create ( const QString &path, int /*w*/, int /*h*/, QImage &img
|
||||||
|
|
||||||
KMimeType::Ptr type = KMimeType::findByPath(path, 0, true);
|
KMimeType::Ptr type = KMimeType::findByPath(path, 0, true);
|
||||||
|
|
||||||
if (type->name() == "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();
|
||||||
TagLib::ID3v2::FrameList fList = mp3Tag->frameList("APIC");
|
TagLib::ID3v2::FrameList fList = mp3Tag->frameList("APIC");
|
||||||
TagLib::ID3v2::AttachedPictureFrame *pic;
|
TagLib::ID3v2::AttachedPictureFrame *pic;
|
||||||
pic = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(fList.front());
|
pic = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(fList.front());
|
||||||
if (!pic->picture().isEmpty()) {
|
if (!pic->picture().isEmpty()) {
|
||||||
#ifndef QT_KATIE
|
|
||||||
img.loadFromData((const uchar *) pic->picture().data(),pic->picture().size());
|
|
||||||
#else
|
|
||||||
img.loadFromData(pic->picture().data(),pic->picture().size());
|
img.loadFromData(pic->picture().data(),pic->picture().size());
|
||||||
#endif
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type->name() == "audio/flac" || type->name() == "audio/x-flac") {
|
} else if (type->is("audio/flac") || type->is("audio/x-flac")) {
|
||||||
TagLib::FLAC::File ff(path.toUtf8());
|
TagLib::FLAC::File ff(path.toUtf8());
|
||||||
TagLib::List<TagLib::FLAC::Picture *> coverList;
|
TagLib::List<TagLib::FLAC::Picture *> coverList;
|
||||||
|
|
||||||
if (!ff.pictureList().isEmpty()) {
|
if (!ff.pictureList().isEmpty()) {
|
||||||
coverList.append(ff.pictureList().front());
|
coverList.append(ff.pictureList().front());
|
||||||
TagLib::ByteVector coverData = coverList.front()->data();
|
TagLib::ByteVector coverData = coverList.front()->data();
|
||||||
QByteArray data;
|
img.loadFromData(coverData.data(),coverData.size());
|
||||||
data.setRawData(coverData.data(),coverData.size());
|
|
||||||
img.loadFromData(data);
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type->name() == "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 *tag = mp4file.tag();
|
||||||
TagLib::MP4::ItemListMap map=tag->itemListMap();
|
TagLib::MP4::ItemListMap map=tag->itemListMap();
|
||||||
QByteArray data;
|
|
||||||
|
|
||||||
if (!map.isEmpty()) {
|
if (!map.isEmpty()) {
|
||||||
for (TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
|
for (TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
|
||||||
|
@ -110,65 +103,36 @@ bool ATCreator::create ( const QString &path, int /*w*/, int /*h*/, QImage &img
|
||||||
TagLib::MP4::CoverArt cover=coverList[0];
|
TagLib::MP4::CoverArt cover=coverList[0];
|
||||||
|
|
||||||
TagLib::ByteVector coverData=cover.data();
|
TagLib::ByteVector coverData=cover.data();
|
||||||
data.setRawData(coverData.data(),coverData.size());
|
img.loadFromData(coverData.data(),coverData.size());
|
||||||
img.loadFromData(data);
|
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type->name() == "audio/x-vorbis+ogg" || type->name() == "audio/ogg") {
|
} else if (type->is("audio/x-vorbis+ogg") || type->is("audio/ogg")) {
|
||||||
// this part from Coquillo audio tag editor
|
|
||||||
TagLib::Ogg::Vorbis::File file(path.toUtf8());
|
TagLib::Ogg::Vorbis::File file(path.toUtf8());
|
||||||
TagLib::Ogg::XiphComment *tag = file.tag();
|
TagLib::Ogg::XiphComment *tag = file.tag();
|
||||||
|
|
||||||
if (tag->contains("METADATA_BLOCK_PICTURE")) {
|
TagLib::List<TagLib::FLAC::Picture*> picturelist = tag->pictureList();
|
||||||
TagLib::StringList blocks = tag->fieldListMap()["METADATA_BLOCK_PICTURE"];
|
for (int i = 0; i < picturelist.size(); i++) {
|
||||||
|
// qDebug() << Q_FUNC_INFO << picturelist[i]->code();
|
||||||
for (uint i = 0; i < blocks.size(); i++) {
|
switch (picturelist[i]->code()) {
|
||||||
QByteArray data = QByteArray::fromBase64(blocks[i].toCString());
|
case TagLib::FLAC::Picture::FrontCover:
|
||||||
QDataStream s(&data, QIODevice::ReadOnly);
|
case TagLib::FLAC::Picture::BackCover:
|
||||||
|
case TagLib::FLAC::Picture::Media: {
|
||||||
int type;
|
break;
|
||||||
uint mimelen;
|
}
|
||||||
int descrlen;
|
default: {
|
||||||
int datalen;
|
continue;
|
||||||
|
break;
|
||||||
int w;
|
}
|
||||||
int h;
|
}
|
||||||
int c;
|
|
||||||
int ic;
|
|
||||||
|
|
||||||
char * mime;
|
|
||||||
char * descr;
|
|
||||||
char * pic;
|
|
||||||
|
|
||||||
s >> type;
|
|
||||||
s >> mimelen;
|
|
||||||
|
|
||||||
mime = new char[mimelen+1];
|
|
||||||
s.readRawData(mime, mimelen);
|
|
||||||
|
|
||||||
mime[mimelen] = 0;
|
|
||||||
|
|
||||||
s >> descrlen;
|
|
||||||
|
|
||||||
descr = new char[descrlen+1];
|
|
||||||
s.readRawData(descr, descrlen);
|
|
||||||
|
|
||||||
descr[descrlen] = 0;
|
|
||||||
|
|
||||||
s >> w >> h >> c >> ic >> datalen;
|
|
||||||
|
|
||||||
if (!datalen)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
pic = new char[datalen];
|
|
||||||
s.readRawData(pic, datalen);
|
|
||||||
img = QImage::fromData(QByteArray(pic, datalen));
|
|
||||||
|
|
||||||
|
img.loadFromData(picturelist[i]->data().data(), picturelist[i]->data().size());
|
||||||
|
if (!img.isNull()) {
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue