mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
commit
b4a33b0306
@ -130,7 +130,38 @@ TagLib::uint APE::Tag::track() const
|
||||
|
||||
TagLib::PictureMap APE::Tag::pictures() const
|
||||
{
|
||||
return PictureMap();
|
||||
PictureMap map;
|
||||
if(d->itemListMap.contains(FRONT_COVER)) {
|
||||
Item front = d->itemListMap[FRONT_COVER];
|
||||
if(Item::Binary == front.type()) {
|
||||
ByteVector picture = front.binaryData();
|
||||
int index = picture.find('\0');
|
||||
if(index < picture.size()) {
|
||||
ByteVector desc = picture.mid(0, index + 1);
|
||||
String mime = "image/jpeg";
|
||||
ByteVector data = picture.mid(index + 1);
|
||||
Picture p(data, Picture::FrontCover, mime, desc);
|
||||
map.insert(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(d->itemListMap.contains(BACK_COVER)) {
|
||||
Item back = d->itemListMap[BACK_COVER];
|
||||
if(Item::Binary == back.type()) {
|
||||
ByteVector picture = back.binaryData();
|
||||
int index = picture.find('\0');
|
||||
if(index < picture.size()) {
|
||||
ByteVector desc = picture.mid(0, index + 1);
|
||||
String mime = "image/jpeg";
|
||||
ByteVector data = picture.mid(index + 1);
|
||||
Picture p(data, Picture::BackCover, mime, desc);
|
||||
map.insert(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PictureMap(map);
|
||||
}
|
||||
|
||||
void APE::Tag::setTitle(const String &s)
|
||||
@ -176,6 +207,59 @@ void APE::Tag::setTrack(uint i)
|
||||
|
||||
void APE::Tag::setPictures(const PictureMap &l)
|
||||
{
|
||||
removeItem(FRONT_COVER);
|
||||
removeItem(BACK_COVER);
|
||||
for(PictureMap::ConstIterator pictureMapIt = l.begin();
|
||||
pictureMapIt != l.end();
|
||||
++pictureMapIt) {
|
||||
Picture::Type type = pictureMapIt->first;
|
||||
if(Picture::FrontCover != type && Picture::BackCover != type) {
|
||||
std::cout << "APE: Trying to add a picture with wrong type"
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *id;
|
||||
switch(type) {
|
||||
case Picture::FrontCover:
|
||||
id = FRONT_COVER;
|
||||
break;
|
||||
case Picture::BackCover:
|
||||
id = BACK_COVER;
|
||||
break;
|
||||
default:
|
||||
id = FRONT_COVER;
|
||||
break;
|
||||
}
|
||||
|
||||
PictureList list = pictureMapIt->second;
|
||||
for(PictureList::ConstIterator pictureListIt = list.begin();
|
||||
pictureListIt != list.end();
|
||||
++pictureListIt) {
|
||||
Picture picture = *pictureListIt;
|
||||
if(d->itemListMap.contains(id)) {
|
||||
std::cout << "APE: Already added a picture of type "
|
||||
<< id
|
||||
<< " '"
|
||||
<< picture.description()
|
||||
<< "' "
|
||||
<< "and next are being ignored"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
ByteVector data = picture.description().data(String::Latin1)
|
||||
.append('\0')
|
||||
.append(picture.data());
|
||||
|
||||
Item item;
|
||||
item.setKey(id);
|
||||
item.setType(Item::Binary);
|
||||
item.setBinaryData(data);
|
||||
setItem(item.key(), item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// conversions of tag keys between what we use in PropertyMap and what's usual
|
||||
|
@ -34,6 +34,9 @@
|
||||
|
||||
#include "apeitem.h"
|
||||
|
||||
#define FRONT_COVER "COVER ART (FRONT)"
|
||||
#define BACK_COVER "COVER ART (BACK)"
|
||||
|
||||
namespace TagLib {
|
||||
|
||||
class File;
|
||||
@ -94,6 +97,14 @@ namespace TagLib {
|
||||
virtual String genre() const;
|
||||
virtual uint year() const;
|
||||
virtual uint track() const;
|
||||
|
||||
/**
|
||||
* @brief pictures
|
||||
* According to :
|
||||
* http://www.hydrogenaud.io/forums/index.php?showtopic=40603&st=50&p=504669&#entry504669
|
||||
* http://git.videolan.org/?p=vlc.git;a=blob;f=modules/meta_engine/taglib.cpp
|
||||
* @return
|
||||
*/
|
||||
virtual PictureMap pictures() const;
|
||||
|
||||
virtual void setTitle(const String &s);
|
||||
|
Loading…
x
Reference in New Issue
Block a user