本文整理汇总了C++中taglib::id3v2::AttachedPictureFrame::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ AttachedPictureFrame::setType方法的具体用法?C++ AttachedPictureFrame::setType怎么用?C++ AttachedPictureFrame::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::id3v2::AttachedPictureFrame
的用法示例。
在下文中一共展示了AttachedPictureFrame::setType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attachPicture
bool MetaDSF::attachPicture(const TagLib::String &path,
const TagLib::String &ptype)
{
// Determine MIME type
TagLib::String mimeType;
TagLib::String ext = path.substr(path.rfind(".") + 1);
transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (extToMIMETypeMap.find(ext) == extToMIMETypeMap.end()) {
std::cerr << "Unknown image format " << ext << std::endl;
return false;
}
mimeType = extToMIMETypeMap[ext];
// Load file into memory
TagLib::ByteVector v;
if (loadFileIntoVector(path.toCString(), v) <= 0) {
return false;
}
std::string pt = ptype.toCString();
TagLib::ID3v2::AttachedPictureFrame *apic =
new TagLib::ID3v2::AttachedPictureFrame();
TagLib::ID3v2::AttachedPictureFrame::Type t =
static_cast<TagLib::ID3v2::AttachedPictureFrame::Type>(std::stoi(pt, 0, 16));
apic->setPicture(v);
apic->setMimeType(mimeType);
apic->setType(t);
_i->_file.ID3v2Tag()->addFrame(apic);
_i->_changed = true;
return true;
}
示例2: buffer
bool
ID3v2TagHelper::setEmbeddedCover( const QImage &cover )
{
QByteArray bytes;
QBuffer buffer( &bytes );
buffer.open( QIODevice::WriteOnly );
if( !cover.save( &buffer, "JPEG" ) )
{
buffer.close();
return false;
}
buffer.close();
TagLib::ByteVector field = fieldName( Meta::valHasCover ).toCString();
TagLib::ID3v2::FrameList apicList = m_tag->frameListMap()[field];
TagLib::ID3v2::AttachedPictureFrame *frontCover = NULL;
// remove covers
TagLib::List<TagLib::ID3v2::AttachedPictureFrame*> backedUpPictures;
for( TagLib::ID3v2::FrameList::ConstIterator it = apicList.begin(); it != apicList.end(); ++it )
{
TagLib::ID3v2::AttachedPictureFrame *currFrame =
dynamic_cast< TagLib::ID3v2::AttachedPictureFrame * >( *it );
m_tag->removeFrame( currFrame, false );
}
// add new cover
frontCover = new TagLib::ID3v2::AttachedPictureFrame( field );
frontCover->setMimeType( "image/jpeg" );
frontCover->setPicture( TagLib::ByteVector( bytes.data(), bytes.count() ) );
frontCover->setType( TagLib::ID3v2::AttachedPictureFrame::FrontCover );
m_tag->addFrame( frontCover );
return true;
}
示例3: if
//.........这里部分代码省略.........
if(nullptr != trackGainFrame)
tag->removeFrame(trackGainFrame);
if(nullptr != trackPeakFrame)
tag->removeFrame(trackPeakFrame);
if(nullptr != albumGainFrame)
tag->removeFrame(albumGainFrame);
if(nullptr != albumPeakFrame)
tag->removeFrame(albumPeakFrame);
if(trackGain) {
SFB::CFString str = CreateStringFromNumberWithFormat(trackGain, kCFNumberDoubleType, CFSTR("%+2.2f dB"));
auto frame = new TagLib::ID3v2::UserTextIdentificationFrame();
frame->setDescription("replaygain_track_gain");
frame->setText(TagLib::StringFromCFString(str));
tag->addFrame(frame);
}
if(trackPeak) {
SFB::CFString str = CreateStringFromNumberWithFormat(trackPeak, kCFNumberDoubleType, CFSTR("%1.8f dB"));
auto frame = new TagLib::ID3v2::UserTextIdentificationFrame();
frame->setDescription("replaygain_track_peak");
frame->setText(TagLib::StringFromCFString(str));
tag->addFrame(frame);
}
if(albumGain) {
SFB::CFString str = CreateStringFromNumberWithFormat(albumGain, kCFNumberDoubleType, CFSTR("%+2.2f dB"));
auto frame = new TagLib::ID3v2::UserTextIdentificationFrame();
frame->setDescription("replaygain_album_gain");
frame->setText(TagLib::StringFromCFString(str));
tag->addFrame(frame);
}
if(albumPeak) {
SFB::CFString str = CreateStringFromNumberWithFormat(albumPeak, kCFNumberDoubleType, CFSTR("%1.8f dB"));
auto frame = new TagLib::ID3v2::UserTextIdentificationFrame();
frame->setDescription("replaygain_album_peak");
frame->setText(TagLib::StringFromCFString(str));
tag->addFrame(frame);
}
// Also write the RVA2 frames
tag->removeFrames("RVA2");
if(trackGain) {
auto relativeVolume = new TagLib::ID3v2::RelativeVolumeFrame();
float f;
CFNumberGetValue(trackGain, kCFNumberFloatType, &f);
relativeVolume->setIdentification(TagLib::String("track", TagLib::String::Latin1));
relativeVolume->setVolumeAdjustment(f, TagLib::ID3v2::RelativeVolumeFrame::MasterVolume);
tag->addFrame(relativeVolume);
}
if(albumGain) {
auto relativeVolume = new TagLib::ID3v2::RelativeVolumeFrame();
float f;
CFNumberGetValue(albumGain, kCFNumberFloatType, &f);
relativeVolume->setIdentification(TagLib::String("album", TagLib::String::Latin1));
relativeVolume->setVolumeAdjustment(f, TagLib::ID3v2::RelativeVolumeFrame::MasterVolume);
tag->addFrame(relativeVolume);
}
// Album art
if(setAlbumArt) {
tag->removeFrames("APIC");
for(auto attachedPicture : metadata.GetAttachedPictures()) {
SFB::CGImageSource imageSource = CGImageSourceCreateWithData(attachedPicture->GetData(), nullptr);
if(!imageSource)
continue;
TagLib::ID3v2::AttachedPictureFrame *frame = new TagLib::ID3v2::AttachedPictureFrame;
// Convert the image's UTI into a MIME type
SFB::CFString mimeType = UTTypeCopyPreferredTagWithClass(CGImageSourceGetType(imageSource), kUTTagClassMIMEType);
if(mimeType)
frame->setMimeType(TagLib::StringFromCFString(mimeType));
frame->setPicture(TagLib::ByteVector((const char *)CFDataGetBytePtr(attachedPicture->GetData()), (TagLib::uint)CFDataGetLength(attachedPicture->GetData())));
frame->setType((TagLib::ID3v2::AttachedPictureFrame::Type)attachedPicture->GetType());
if(attachedPicture->GetDescription())
frame->setDescription(TagLib::StringFromCFString(attachedPicture->GetDescription()));
tag->addFrame(frame);
}
}
return true;
}