本文整理汇总了C++中taglib::mpeg::File类的典型用法代码示例。如果您正苦于以下问题:C++ File类的具体用法?C++ File怎么用?C++ File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了File类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OpenFile
bool MetaIOID3::writeVolatileMetadata(const Metadata* mdata)
{
QString filename = mdata->Filename();
int rating = mdata->Rating();
int playcount = mdata->PlayCount();
TagLib::MPEG::File *mpegfile = OpenFile(filename);
if (!mpegfile)
return false;
TagLib::ID3v2::Tag *tag = mpegfile->ID3v2Tag();
if (!tag)
{
delete mpegfile;
return false;
}
bool result = (writeRating(tag, rating) && writePlayCount(tag, playcount));
mpegfile->save();
delete mpegfile;
return result;
}
开发者ID:pierrchen,项目名称:mythtv,代码行数:25,代码来源:metaioid3.cpp
示例2: rating
/** Convert the existing rating number into a smaller range from 1 to 5. */
int FileHelper::rating() const
{
int r = -1;
/// TODO other types?
switch (_fileType) {
case EXT_MP3: {
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
if (mpegFile && mpegFile->hasID3v2Tag()) {
r = this->ratingForID3v2(mpegFile->ID3v2Tag());
}
break;
}
case EXT_FLAC: {
if (TagLib::FLAC::File *flacFile = static_cast<TagLib::FLAC::File*>(_file)) {
if (flacFile->hasID3v2Tag()) {
r = this->ratingForID3v2(flacFile->ID3v2Tag());
} else if (flacFile->hasID3v1Tag()) {
qDebug() << Q_FUNC_INFO << "Not implemented (FLAC ID3v1)";
} else if (flacFile->hasXiphComment()) {
TagLib::StringList list = flacFile->xiphComment()->fieldListMap()["RATING"];
if (!list.isEmpty()) {
r = list.front().toInt();
}
}
}
break;
}
default:
break;
}
return r;
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例3: on_pushOpenFolder_clicked
void MainWindow::on_pushOpenFolder_clicked()
{
m_notUsed.clear();
QString dir = QFileDialog::getExistingDirectory(this, tr("Open MP3 Source Directory"),
pSet->value("src_dir").toString(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (!dir.isEmpty())
{
pSet->setValue("src_dir", dir);
ui->lineSrcFolder->setText(dir);
cleanTags();
QDir mp3Dir(dir, "*.mp3");
QStringList files = mp3Dir.entryList();
TagLib::MPEG::File* ptlFile;
foreach (QString file, files)
{
QString path = QString("%1/%2").arg(mp3Dir.absolutePath()).arg(file);
ptlFile = new TagLib::MPEG::File(reinterpret_cast<const wchar_t *>(path.utf16()));
if (ptlFile && ptlFile->isOpen())
{
tagFiles.append(ptlFile);
}
else if(ptlFile)
{
m_notUsed.append(path);
delete ptlFile;
}
}
开发者ID:Jo2003,项目名称:RandomCD,代码行数:33,代码来源:mainwindow.cpp
示例4: setRating
/** Set or remove any rating. */
void FileHelper::setRating(int rating)
{
switch (_fileType) {
case EXT_MP3: {
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
if (mpegFile->hasID3v2Tag()) {
this->setRatingForID3v2(rating, mpegFile->ID3v2Tag());
} else if (mpegFile->hasID3v1Tag()) {
qDebug() << Q_FUNC_INFO << "Not implemented for ID3v1Tag";
}
break;
}
case EXT_FLAC: {
TagLib::FLAC::File *flacFile = static_cast<TagLib::FLAC::File*>(_file);
if (flacFile->hasID3v2Tag()) {
this->setRatingForID3v2(rating, flacFile->ID3v2Tag());
} else if (flacFile->hasID3v1Tag()) {
qDebug() << Q_FUNC_INFO << "hasID3v1Tag";
} else if (flacFile->hasXiphComment()) {
TagLib::Ogg::XiphComment *xiph = flacFile->xiphComment();
if (rating == 0) {
xiph->removeField("RATING");
} else {
xiph->addField("RATING", QString::number(rating).toStdString());
}
}
break;
}
default:
break;
}
this->save();
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例5: QImage
/*!
* \brief Read the albumart image from the file
*
* \param filename The filename for which we want to find the length.
* \param type The type of image we want - front/back etc
* \returns A pointer to a QImage owned by the caller or NULL if not found.
*/
QImage* MetaIOID3::getAlbumArt(QString filename, ImageType type)
{
QImage *picture = new QImage();
AttachedPictureFrame::Type apicType
= AttachedPictureFrame::FrontCover;
switch (type)
{
case IT_UNKNOWN :
apicType = AttachedPictureFrame::Other;
break;
case IT_FRONTCOVER :
apicType = AttachedPictureFrame::FrontCover;
break;
case IT_BACKCOVER :
apicType = AttachedPictureFrame::BackCover;
break;
case IT_CD :
apicType = AttachedPictureFrame::Media;
break;
case IT_INLAY :
apicType = AttachedPictureFrame::LeafletPage;
break;
default:
return picture;
}
QByteArray fname = filename.toLocal8Bit();
TagLib::MPEG::File *mpegfile = new TagLib::MPEG::File(fname.constData());
if (mpegfile)
{
if (mpegfile->isOpen()
&& !mpegfile->ID3v2Tag()->frameListMap()["APIC"].isEmpty())
{
TagLib::ID3v2::FrameList apicframes =
mpegfile->ID3v2Tag()->frameListMap()["APIC"];
for(TagLib::ID3v2::FrameList::Iterator it = apicframes.begin();
it != apicframes.end(); ++it)
{
AttachedPictureFrame *frame =
static_cast<AttachedPictureFrame *>(*it);
if (frame && frame->type() == apicType)
{
picture->loadFromData((const uchar *)frame->picture().data(),
frame->picture().size());
return picture;
}
}
}
delete mpegfile;
}
delete picture;
return NULL;
}
开发者ID:pierrchen,项目名称:mythtv,代码行数:67,代码来源:metaioid3.cpp
示例6: hasCover
/** Check if file has an inner picture. */
bool FileHelper::hasCover() const
{
bool atLeastOnePicture = false;
switch (_fileType) {
case EXT_MP3: {
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
if (mpegFile && mpegFile->hasID3v2Tag()) {
// Look for picture frames only
TagLib::ID3v2::FrameList listOfMp3Frames = mpegFile->ID3v2Tag()->frameListMap()["APIC"];
// It's possible to have more than one picture per file!
if (!listOfMp3Frames.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = listOfMp3Frames.begin(); it != listOfMp3Frames.end() ; it++) {
// Cast a Frame* to AttachedPictureFrame*
TagLib::ID3v2::AttachedPictureFrame *pictureFrame = static_cast<TagLib::ID3v2::AttachedPictureFrame*>(*it);
atLeastOnePicture = atLeastOnePicture || (pictureFrame != nullptr && !pictureFrame->picture().isEmpty());
}
}
}
break;
}
case EXT_FLAC: {
if (TagLib::FLAC::File *flacFile = static_cast<TagLib::FLAC::File*>(_file)) {
atLeastOnePicture = !flacFile->pictureList().isEmpty();
}
}
default:
break;
}
return atLeastOnePicture;
}
开发者ID:,项目名称:,代码行数:31,代码来源:
示例7:
/**
* When make sure an apetag is there, so that saving a mp3 file back
* can include apetags too.
*
* This is needed, since taglib will only create apetags in mp3 files
* if that is explicitly requested.
*
* Only use this for FT_MPEG files. Other types may not have the required
* method, which will cause fatal problems.
*
* @param file TagLib_File pointer to the mp3 in question.
*
* @return void
* @sideeffects none
*/
void
mp3_dotheape(TagLib_File *file)
{
TagLib::MPEG::File *f;
f = reinterpret_cast<TagLib::MPEG::File *>(file);
f->APETag(true);
}
开发者ID:pft,项目名称:taggit,代码行数:23,代码来源:taglib_ext.cpp
示例8: switch
/*!
* \brief Remove the albumart image from the file
*
* \param filename The music file to remove the albumart
* \param albumart The Album Art image to remove
* \returns True if successful
*/
bool MetaIOID3::removeAlbumArt(const QString &filename, const AlbumArtImage *albumart)
{
if (filename.isEmpty() || !albumart)
return false;
AttachedPictureFrame::Type type = AttachedPictureFrame::Other;
switch (albumart->imageType)
{
case IT_FRONTCOVER:
type = AttachedPictureFrame::FrontCover;
break;
case IT_BACKCOVER:
type = AttachedPictureFrame::BackCover;
break;
case IT_CD:
type = AttachedPictureFrame::Media;
break;
case IT_INLAY:
type = AttachedPictureFrame::LeafletPage;
break;
default:
type = AttachedPictureFrame::Other;
break;
}
TagLib::MPEG::File *mpegfile = OpenFile(filename);
if (!mpegfile)
return false;
TagLib::ID3v2::Tag *tag = mpegfile->ID3v2Tag();
if (!tag)
{
delete mpegfile;
return false;
}
AttachedPictureFrame *apic = findAPIC(tag, type, QStringToTString(albumart->description));
if (!apic)
{
delete mpegfile;
return false;
}
tag->removeFrame(apic);
mpegfile->save();
delete mpegfile;
return true;
}
开发者ID:pierrchen,项目名称:mythtv,代码行数:59,代码来源:metaioid3.cpp
示例9:
/*!
* \brief Open the file to read the tag
*
* \param filename The filename
* \returns A taglib file object for this format
*/
TagLib::MPEG::File *MetaIOID3::OpenFile(const QString &filename)
{
QByteArray fname = filename.toLocal8Bit();
TagLib::MPEG::File *mpegfile = new TagLib::MPEG::File(fname.constData());
if (!mpegfile->isOpen())
{
delete mpegfile;
mpegfile = NULL;
}
return mpegfile;
}
开发者ID:pierrchen,项目名称:mythtv,代码行数:19,代码来源:metaioid3.cpp
示例10: save
bool FileHelper::save()
{
if (_fileType == EXT_MP3) {
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
// TagLib updates tags with the latest version (ID3v2.4)
// We just want to save the file with the exact same version!
if (mpegFile->hasID3v2Tag()) {
return mpegFile->save(TagLib::MPEG::File::AllTags, false, mpegFile->ID3v2Tag()->header()->majorVersion());
}
} else if (_fileType != EXT_UNKNOWN) {
return _file->save();
}
return false;
}
开发者ID:,项目名称:,代码行数:14,代码来源:
示例11: strip
void
MetaBundle::readTags( TagLib::AudioProperties::ReadStyle readStyle )
{
if( m_url.protocol() != "file" )
return;
const QString path = m_url.path();
TagLib::FileRef fileref;
TagLib::Tag *tag = 0;
if( AmarokConfig::recodeID3v1Tags() && path.endsWith( ".mp3", false ) )
{
TagLib::MPEG::File *mpeg = new TagLib::MPEG::File( QFile::encodeName( path ), true, readStyle );
fileref = TagLib::FileRef( mpeg );
if( mpeg->isValid() )
// we prefer ID3v1 over ID3v2 if recoding tags because
// apparently this is what people who ignore ID3 standards want
tag = mpeg->ID3v1Tag() ? (TagLib::Tag*)mpeg->ID3v1Tag() : (TagLib::Tag*)mpeg->ID3v2Tag();
}
else {
fileref = TagLib::FileRef( QFile::encodeName( path ), true, readStyle );
if( !fileref.isNull() )
tag = fileref.tag();
}
if( !fileref.isNull() ) {
if ( tag ) {
#define strip( x ) TStringToQString( x ).stripWhiteSpace()
m_title = strip( tag->title() );
m_artist = strip( tag->artist() );
m_album = strip( tag->album() );
m_comment = strip( tag->comment() );
m_genre = strip( tag->genre() );
m_year = tag->year() ? QString::number( tag->year() ) : QString();
m_track = tag->track() ? QString::number( tag->track() ) : QString();
#undef strip
m_isValidMedia = true;
}
init( fileref.audioProperties() );
}
//FIXME disabled for beta4 as it's simpler to not got 100 bug reports
//else if( KMimeType::findByUrl( m_url )->is( "audio" ) )
// init( KFileMetaInfo( m_url, QString::null, KFileMetaInfo::Everything ) );
}
开发者ID:,项目名称:,代码行数:50,代码来源:
示例12: TStringToQString
TagLib::Tag *mttFile::getTag( bool create )
{
if ( tag == NULL ) {
fileref = new TagLib::FileRef( QFile::encodeName( fname ).constData() );
if ( fileref ) {
if ( ismpeg ) {
TagLib::MPEG::File *f = dynamic_cast<TagLib::MPEG::File *>(fileref->file());
tag = new TagLib::ID3v2::Tag();
if ( f->ID3v2Tag( create ) != NULL ) {
TagLib::Tag::duplicate( dynamic_cast<TagLib::Tag *>( f->ID3v2Tag( create ) ), tag, true );
// Read extra mp3 tags
int i;
for ( i = 0; i < EF_NUM; i++ ) {
TagLib::ID3v2::FrameList l = f->ID3v2Tag()->frameListMap()[extraFrames[i][0]];
if ( !l.isEmpty() ) {
mp3eframes += extraFrames[i][0];
mp3eframes += TStringToQString( l.front()->toString() );
}
}
}
delete fileref;
fileref = NULL;
return tag;
}
else { // If the file is ogg or flac
tag = new TagLib::Ogg::XiphComment();
if ( fileref->tag() ) // If a tag already exists
TagLib::Tag::duplicate( fileref->tag(), tag, true );
delete fileref;
fileref = NULL;
return tag;
}
}
else {
//qDebug( "fileref = NULL" );
return NULL;
}
delete fileref;
fileref = NULL;
}
else
return tag;
}
开发者ID:BackupTheBerlios,项目名称:mediatagtools,代码行数:49,代码来源:mttfile.cpp
示例13: setArtistAlbum
void FileHelper::setArtistAlbum(const QString &artistAlbum)
{
switch (_fileType) {
case EXT_FLAC: {
this->setFlacAttribute("ALBUMARTIST", artistAlbum);
break;
}
case EXT_MP4:{
TagLib::StringList l;
l.append(artistAlbum.toStdString().data());
TagLib::MP4::Item item(l);
this->setMp4Attribute("aART", item);
break;
}
case EXT_MPC:
//mpcFile = static_cast<MPC::File*>(f);
qDebug() << Q_FUNC_INFO << "Not implemented for MPC";
break;
case EXT_MP3:{
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
if (mpegFile->hasID3v2Tag()) {
TagLib::ID3v2::Tag *tag = mpegFile->ID3v2Tag();
QString convertedKey = this->convertKeyToID3v2Key("ARTISTALBUM");
TagLib::ID3v2::FrameList l = tag->frameListMap()[convertedKey.toStdString().data()];
if (!l.isEmpty()) {
tag->removeFrame(l.front());
}
TagLib::ID3v2::TextIdentificationFrame *tif = new TagLib::ID3v2::TextIdentificationFrame(TagLib::ByteVector(convertedKey.toStdString().data()));
tif->setText(artistAlbum.toStdString().data());
tag->addFrame(tif);
} else if (mpegFile->hasID3v1Tag()) {
qDebug() << Q_FUNC_INFO << "Not implemented for ID3v1Tag";
}
break;
}
case EXT_OGG: {
TagLib::Ogg::XiphComment *xiphComment = static_cast<TagLib::Ogg::XiphComment*>(_file->tag());
if (xiphComment) {
xiphComment->addField("ALBUMARTIST", artistAlbum.toStdString().data());
} else {
qDebug() << Q_FUNC_INFO << "Not implemented for this OGG file";
}
break;
}
default:
qDebug() << Q_FUNC_INFO << "Not implemented for this type of file";
break;
}
}
开发者ID:,项目名称:,代码行数:49,代码来源:
示例14: GetComposer
bool CCover::GetComposer(TagLib::FileRef& fr, std::string& composer)
{
TagLib::MPEG::File * mpgfile = NULL;
TagLib::Ogg::Vorbis::File * oggfile = NULL;
TagLib::FLAC::File * flacfile = NULL;
TagLib::Ogg::XiphComment * xiph = NULL;
TagLib::ID3v2::Tag * id3v2 = NULL;
#ifdef TAGLIB_HAVE_MP4
TagLib::MP4::File * mp4file = NULL;
TagLib::MP4::Tag * mp4 = NULL;
#endif
if ((oggfile = dynamic_cast<TagLib::Ogg::Vorbis::File*>(fr.file()))) {
xiph=oggfile->tag();
//log_debug("ogg");
} else if ((flacfile = dynamic_cast<TagLib::FLAC::File*>(fr.file()))) {
xiph=flacfile->xiphComment();
id3v2=flacfile->ID3v2Tag();
//log_debug("flac");
} else if ((mpgfile = dynamic_cast<TagLib::MPEG::File*>(fr.file()))) {
id3v2=mpgfile->ID3v2Tag();
//log_debug("mpg");
}
#ifdef TAGLIB_HAVE_MP4
else if ((mp4file = dynamic_cast<TagLib::MP4::File*>(fr.file()))) {
mp4=mp4file->tag();
}
#endif
#ifndef TAGLIB_HAVE_MP4
void* mp4 = NULL;
#endif
//log_debug4("xiph=%p, id3v2=%p, mp4=%p", xiph, id3v2, mp4);
bool retval = true;
if (xiph)
retval = xiph_get_field(xiph, "COMPOSER",composer);
else if (id3v2)
retval = id3v2_get_field(id3v2, "TCOM",composer);
#ifdef TAGLIB_HAVE_MP4
else if (mp4)
retval = mp4_get_field(mp4file, "\251wrt",composer);
#endif
else
retval = false;
//log_debug2("composer = %s", composer.c_str());
return retval;
}
开发者ID:hdijkema,项目名称:libtagcoverart,代码行数:49,代码来源:tagcoverart.cpp
示例15: addImage
bool CTagBase::addImage(wchar_t* s)
{
if (!_tagFile) return false;
TagLib::MPEG::File *pAudioFile = (TagLib::MPEG::File *)_tagFile.get();
CString strFileName = s;
ImageFile imageFile((CW2A)strFileName.GetBuffer());
if (!pAudioFile->isValid() || !imageFile.isValid())
return false;
TagLib::ID3v2::Tag *tag = pAudioFile->ID3v2Tag(true);
TagLib::ID3v2::AttachedPictureFrame *frame = new TagLib::ID3v2::AttachedPictureFrame;
frame->setMimeType(imageFile.mimeType());
frame->setPicture(imageFile.data());
tag->addFrame(frame);
return pAudioFile->save();
}
开发者ID:hjhong,项目名称:MyDuiLib,代码行数:16,代码来源:tagBase.cpp
示例16: extractCover
Cover* FileHelper::extractCover()
{
Cover *cover = nullptr;
switch (_fileType) {
case EXT_MP3: {
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
if (mpegFile && mpegFile->hasID3v2Tag()) {
// Look for picture frames only
TagLib::ID3v2::FrameList listOfMp3Frames = mpegFile->ID3v2Tag()->frameListMap()["APIC"];
// It's possible to have more than one picture per file!
if (!listOfMp3Frames.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = listOfMp3Frames.begin(); it != listOfMp3Frames.end() ; it++) {
// Cast a Frame* to AttachedPictureFrame*
TagLib::ID3v2::AttachedPictureFrame *pictureFrame = static_cast<TagLib::ID3v2::AttachedPictureFrame*>(*it);
if (pictureFrame) {
// Performs a deep copy of the cover
QByteArray b = QByteArray(pictureFrame->picture().data(), pictureFrame->picture().size());
cover = new Cover(b, QString(pictureFrame->mimeType().toCString(true)));
}
}
}
} else if (mpegFile && mpegFile->hasID3v1Tag()) {
qDebug() << Q_FUNC_INFO << "Not implemented for ID3v1Tag";
}
break;
}
case EXT_FLAC: {
if (TagLib::FLAC::File *flacFile = static_cast<TagLib::FLAC::File*>(_file)) {
auto list = flacFile->pictureList();
for (auto it = list.begin(); it != list.end() ; it++) {
TagLib::FLAC::Picture *p = *it;
if (p->type() == TagLib::FLAC::Picture::FrontCover) {
// Performs a deep copy of the cover
QByteArray b = QByteArray(p->data().data(), p->data().size());
cover = new Cover(b, QString(p->mimeType().toCString(true)));
break;
}
}
}
break;
}
default:
qDebug() << Q_FUNC_INFO << "Not implemented for this file type" << _fileType << _file << _fileInfo.absoluteFilePath();
break;
}
return cover;
}
开发者ID:,项目名称:,代码行数:47,代码来源:
示例17: exportImage
bool CTagBase::exportImage(const wchar_t* s)
{
if (!s) return false;
if (_tagFile)
{
//get picture
TagLib::MPEG::File *f = (TagLib::MPEG::File *)_tagFile.get();
if (!f->hasID3v2Tag() || f->ID3v2Tag()->isEmpty())
return false;
/*
TagLib::ID3v2::FrameList::ConstIterator it = f->ID3v2Tag()->frameList().begin();
for (; it != f->ID3v2Tag()->frameList().end(); it++)
{
if ((*it)->frameID().operator == (TagLib::ByteVector("APIC")))
{
HANDLE hFile = CreateFile(s, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == hFile)
return false;
int nWriteBytes = 0;
size_t size = (*it)->size();
::WriteFile(hFile, (*it)->render().data(), (*it)->size(), (LPDWORD)&nWriteBytes, NULL);
::CloseHandle(hFile);
if (nWriteBytes != size)
return false;
return true;
}
}*/
if (f->ID3v2Tag()->frameListMap().size() == 0)
return false;
if (f->ID3v2Tag()->frameListMap().find("APIC") == f->ID3v2Tag()->frameListMap().end())
return false;
TagLib::ID3v2::FrameList Flist = f->ID3v2Tag()->frameListMap()["APIC"];
if (Flist.isEmpty())
return false;
TagLib::ID3v2::AttachedPictureFrame *p = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(Flist.front());
size_t size = p->picture().size();
CString strPicType = p->mimeType().toCString(true);
int nPos = strPicType.Find('/');
CString strTemp = strPicType.Right(strPicType.GetLength() - nPos - 1);
//CString strPicPath = s;
//if (strTemp == _T("png"))
// strPicPath.Append(_T(".png"));
//else
// strPicPath.Append(_T(".jpg"));
HANDLE hFile = CreateFile(s, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == hFile)
return false;
int nWriteBytes = 0;
::WriteFile(hFile, p->picture().data(), size, (LPDWORD)&nWriteBytes, NULL);
::CloseHandle(hFile);
if (nWriteBytes != size)
return false;
return true;
}
return false;
}
开发者ID:hjhong,项目名称:MyDuiLib,代码行数:60,代码来源:tagBase.cpp
示例18: setDiscNumber
/** Set or remove any disc number. */
void FileHelper::setDiscNumber(const QString &disc)
{
switch (_fileType) {
case EXT_FLAC: {
this->setFlacAttribute("DISCNUMBER", disc);
break;
}
case EXT_OGG: {
TagLib::Ogg::XiphComment *xiphComment = static_cast<TagLib::Ogg::XiphComment*>(_file->tag());
if (xiphComment) {
xiphComment->addField("DISCNUMBER", disc.toStdString().data());
} else {
qDebug() << Q_FUNC_INFO << "Not implemented for this OGG file";
}
break;
}
case EXT_MP3: {
TagLib::MPEG::File *mpegFile = static_cast<TagLib::MPEG::File*>(_file);
if (mpegFile && mpegFile->hasID3v2Tag()) {
// Remove existing disc number if one has set an empty string
if (disc.isEmpty()) {
mpegFile->ID3v2Tag()->removeFrames(TagLib::ByteVector("TPOS"));
} else {
TagLib::ID3v2::TextIdentificationFrame *f = new TagLib::ID3v2::TextIdentificationFrame(TagLib::ByteVector("TPOS"));
f->setText(disc.toStdString());
mpegFile->ID3v2Tag()->addFrame(f);
}
}
break;
}
case EXT_MP4: {
TagLib::MP4::Item item(disc.toUInt());
this->setMp4Attribute("disk", item);
break;
}
default:
qDebug() << Q_FUNC_INFO << "Not implemented for this file type";
break;
}
}
开发者ID:,项目名称:,代码行数:41,代码来源:
示例19: saveTag
bool mttFile::saveTag( void )
{
fileref = new TagLib::FileRef( QFile::encodeName( fname ).constData() );
if ( ismpeg ) {
TagLib::MPEG::File *f = dynamic_cast<TagLib::MPEG::File *>(fileref->file());
// Remove id3v1 tag. Help put that hack into eternal rest :-)
f->strip( TagLib::MPEG::File::ID3v1, true );
//qDebug("ID3v1 tag stripped!");
TagLib::Tag::duplicate( tag, dynamic_cast<TagLib::Tag *>( f->ID3v2Tag( true ) ), true );
// Save extra mp3 tags
TagLib::ID3v2::TextIdentificationFrame *myframe;
TagLib::ID3v2::Tag *mytag;
mytag = f->ID3v2Tag( false );
for ( QStringList::Iterator it = mp3eframes.begin(); it != mp3eframes.end(); ++it ) {
myframe = new TagLib::ID3v2::TextIdentificationFrame( (*it).toAscii().constData(), TagLib::String::UTF8 );
mytag->removeFrames( (*it).toAscii().constData() );
++it;
myframe->setText( Q4StringToTString( (*it) ) );
mytag->addFrame( myframe );
}
delete fileref;
fileref = NULL;
return f->save( TagLib::MPEG::File::ID3v2, true );
}
else {
TagLib::Tag::duplicate( tag, fileref->tag(), true );
delete fileref;
fileref = NULL;
return fileref->save();
}
}
开发者ID:BackupTheBerlios,项目名称:mediatagtools,代码行数:39,代码来源:mttfile.cpp
示例20: readAlbumArt
/*!
* \brief Read the albumart images from the file
*
* \param filename The filename for which we want to find the images.
*/
AlbumArtList MetaIOID3::getAlbumArtList(const QString &filename)
{
AlbumArtList imageList;
QByteArray fname = filename.toLocal8Bit();
TagLib::MPEG::File *mpegfile = new TagLib::MPEG::File(fname.constData());
if (mpegfile)
{
TagLib::ID3v2::Tag *tag = mpegfile->ID3v2Tag();
if (!tag)
{
delete mpegfile;
return imageList;
}
imageList = readAlbumArt(tag);
delete mpegfile;
}
return imageList;
}
开发者ID:pierrchen,项目名称:mythtv,代码行数:28,代码来源:metaioid3.cpp
注:本文中的taglib::mpeg::File类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论