本文整理汇总了C++中CMusicInfoTag::SetPartOfSet方法的典型用法代码示例。如果您正苦于以下问题:C++ CMusicInfoTag::SetPartOfSet方法的具体用法?C++ CMusicInfoTag::SetPartOfSet怎么用?C++ CMusicInfoTag::SetPartOfSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMusicInfoTag
的用法示例。
在下文中一共展示了CMusicInfoTag::SetPartOfSet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseAPETag
bool CTagLoaderTagLib::ParseAPETag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTag& tag)
{
if (!ape)
return false;
const APE::ItemListMap itemListMap = ape->itemListMap();
for (APE::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it)
{
if (it->first == "ARTIST") SetArtist(tag, StringListToVectorString(it->second.toStringList()));
else if (it->first == "ALBUM ARTIST") SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList()));
else if (it->first == "ALBUM") tag.SetAlbum(it->second.toString().to8Bit(true));
else if (it->first == "TITLE") tag.SetTitle(it->second.toString().to8Bit(true));
else if (it->first == "TRACKNUMBER") tag.SetTrackNumber(it->second.toString().toInt());
else if (it->first == "DISCNUMBER") tag.SetPartOfSet(it->second.toString().toInt());
else if (it->first == "YEAR") tag.SetYear(it->second.toString().toInt());
else if (it->first == "GENRE") SetGenre(tag, StringListToVectorString(it->second.toStringList()));
else if (it->first == "COMMENT") tag.SetComment(it->second.toString().to8Bit(true));
else if (it->first == "ENCODEDBY") {}
else if (it->first == "COMPILATION") tag.SetCompilation(it->second.toString().toInt() == 1);
else if (it->first == "LYRICS") tag.SetLyrics(it->second.toString().to8Bit(true));
else if (it->first == "REPLAYGAIN_TRACK_GAIN") tag.SetReplayGainTrackGain((int)(atof(it->second.toString().toCString(true)) * 100 + 0.5));
else if (it->first == "REPLAYGAIN_ALBUM_GAIN") tag.SetReplayGainAlbumGain((int)(atof(it->second.toString().toCString(true)) * 100 + 0.5));
else if (it->first == "REPLAYGAIN_TRACK_PEAK") tag.SetReplayGainTrackPeak((float)atof(it->second.toString().toCString(true)));
else if (it->first == "REPLAYGAIN_ALBUM_PEAK") tag.SetReplayGainAlbumPeak((float)atof(it->second.toString().toCString(true)));
else if (it->first == "MUSICBRAINZ_ARTISTID") tag.SetMusicBrainzArtistID(it->second.toString().to8Bit(true));
else if (it->first == "MUSICBRAINZ_ALBUMARTISTID") tag.SetMusicBrainzAlbumArtistID(it->second.toString().to8Bit(true));
else if (it->first == "MUSICBRAINZ_ALBUMID") tag.SetMusicBrainzAlbumID(it->second.toString().to8Bit(true));
else if (it->first == "MUSICBRAINZ_TRACKID") tag.SetMusicBrainzTrackID(it->second.toString().to8Bit(true));
else if (g_advancedSettings.m_logLevel == LOG_LEVEL_MAX)
CLog::Log(LOGDEBUG, "unrecognized APE tag: %s", it->first.toCString(true));
}
return true;
}
示例2: if
bool CTagLoaderTagLib::ParseMP4Tag(MP4::Tag *mp4, EmbeddedArt *art, CMusicInfoTag& tag)
{
if (!mp4)
return false;
MP4::ItemListMap& itemListMap = mp4->itemListMap();
for (MP4::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it)
{
if (it->first == "\251nam") tag.SetTitle(it->second.toStringList().front().to8Bit(true));
else if (it->first == "\251ART") SetArtist(tag, StringListToVectorString(it->second.toStringList()));
else if (it->first == "\251alb") tag.SetAlbum(it->second.toStringList().front().to8Bit(true));
else if (it->first == "aART") SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList()));
else if (it->first == "\251gen") SetGenre(tag, StringListToVectorString(it->second.toStringList()));
else if (it->first == "\251cmt") tag.SetComment(it->second.toStringList().front().to8Bit(true));
else if (it->first == "cpil") tag.SetCompilation(it->second.toBool());
else if (it->first == "trkn") tag.SetTrackNumber(it->second.toIntPair().first);
else if (it->first == "disk") tag.SetPartOfSet(it->second.toIntPair().first);
else if (it->first == "\251day") tag.SetYear(it->second.toStringList().front().toInt());
else if (it->first == "----:com.apple.iTunes:MusicBrainz Artist Id")
tag.SetMusicBrainzArtistID(it->second.toStringList().front().to8Bit(true));
else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Artist Id")
tag.SetMusicBrainzAlbumArtistID(it->second.toStringList().front().to8Bit(true));
else if (it->first == "----:com.apple.iTunes:MusicBrainz Album Id")
tag.SetMusicBrainzAlbumID(it->second.toStringList().front().to8Bit(true));
else if (it->first == "----:com.apple.iTunes:MusicBrainz Track Id")
tag.SetMusicBrainzTrackID(it->second.toStringList().front().to8Bit(true));
else if (it->first == "covr")
{
MP4::CoverArtList coverArtList = it->second.toCoverArtList();
for (MP4::CoverArtList::ConstIterator pt = coverArtList.begin(); pt != coverArtList.end(); ++pt)
{
string mime;
switch (pt->format())
{
case MP4::CoverArt::PNG:
mime = "image/png";
break;
case MP4::CoverArt::JPEG:
mime = "image/jpeg";
break;
default:
break;
}
if (mime.empty())
continue;
tag.SetCoverArtInfo(pt->data().size(), mime);
if (art)
art->set((const uint8_t *)pt->data().data(), pt->data().size(), mime);
break; // one is enough
}
}
}
return true;
}
示例3: ParseASF
bool CTagLoaderTagLib::ParseASF(ASF::Tag *asf, EmbeddedArt *art, CMusicInfoTag& tag)
{
if (!asf)
return false;
tag.SetTitle(asf->title().to8Bit(true));
const ASF::AttributeListMap& attributeListMap = asf->attributeListMap();
for (ASF::AttributeListMap::ConstIterator it = attributeListMap.begin(); it != attributeListMap.end(); ++it)
{
if (it->first == "Author") SetArtist(tag, GetASFStringList(it->second));
else if (it->first == "WM/AlbumArtist") SetAlbumArtist(tag, GetASFStringList(it->second));
else if (it->first == "WM/AlbumTitle") tag.SetAlbum(it->second.front().toString().to8Bit(true));
else if (it->first == "WM/TrackNumber" ||
it->first == "WM/Track")
{
if (it->second.front().type() == ASF::Attribute::DWordType)
tag.SetTrackNumber(it->second.front().toUInt());
else
tag.SetTrackNumber(atoi(it->second.front().toString().toCString(true)));
}
else if (it->first == "WM/PartOfSet") tag.SetPartOfSet(atoi(it->second.front().toString().toCString(true)));
else if (it->first == "WM/Genre") SetGenre(tag, GetASFStringList(it->second));
else if (it->first == "WM/AlbumArtistSortOrder") {} // Known unsupported, supress warnings
else if (it->first == "WM/ArtistSortOrder") {} // Known unsupported, supress warnings
else if (it->first == "WM/Script") {} // Known unsupported, supress warnings
else if (it->first == "WM/Year") tag.SetYear(atoi(it->second.front().toString().toCString(true)));
else if (it->first == "MusicBrainz/Artist Id") tag.SetMusicBrainzArtistID(GetASFStringList(it->second));
else if (it->first == "MusicBrainz/Album Id") tag.SetMusicBrainzAlbumID(it->second.front().toString().to8Bit(true));
else if (it->first == "MusicBrainz/Album Artist") SetAlbumArtist(tag, GetASFStringList(it->second));
else if (it->first == "MusicBrainz/Album Artist Id") tag.SetMusicBrainzAlbumArtistID(GetASFStringList(it->second));
else if (it->first == "MusicBrainz/Track Id") tag.SetMusicBrainzTrackID(it->second.front().toString().to8Bit(true));
else if (it->first == "MusicBrainz/Album Status") {}
else if (it->first == "MusicBrainz/Album Type") {}
else if (it->first == "MusicIP/PUID") {}
else if (it->first == "replaygain_track_gain") tag.SetReplayGainTrackGain((int)(atof(it->second.front().toString().toCString(true)) * 100 + 0.5));
else if (it->first == "replaygain_album_gain") tag.SetReplayGainAlbumGain((int)(atof(it->second.front().toString().toCString(true)) * 100 + 0.5));
else if (it->first == "replaygain_track_peak") tag.SetReplayGainTrackPeak((float)atof(it->second.front().toString().toCString(true)));
else if (it->first == "replaygain_album_peak") tag.SetReplayGainAlbumPeak((float)atof(it->second.front().toString().toCString(true)));
else if (it->first == "WM/Picture")
{ // picture
ASF::Picture pic = it->second.front().toPicture();
tag.SetCoverArtInfo(pic.picture().size(), pic.mimeType().toCString());
if (art)
art->set((const uint8_t *)pic.picture().data(), pic.picture().size(), pic.mimeType().toCString());
}
else if (g_advancedSettings.m_logLevel == LOG_LEVEL_MAX)
CLog::Log(LOGDEBUG, "unrecognized ASF tag name: %s", it->first.toCString(true));
}
// artist may be specified in the ContentDescription block rather than using the 'Author' attribute.
if (tag.GetArtist().empty())
tag.SetArtist(asf->artist().toCString(true));
tag.SetLoaded(true);
return true;
}
示例4: ParseXiphComment
bool CTagLoaderTagLib::ParseXiphComment(Ogg::XiphComment *xiph, EmbeddedArt *art, CMusicInfoTag& tag)
{
if (!xiph)
return false;
const Ogg::FieldListMap& fieldListMap = xiph->fieldListMap();
for (Ogg::FieldListMap::ConstIterator it = fieldListMap.begin(); it != fieldListMap.end(); ++it)
{
if (it->first == "ARTIST") SetArtist(tag, StringListToVectorString(it->second));
else if (it->first == "ALBUMARTIST") SetAlbumArtist(tag, StringListToVectorString(it->second));
else if (it->first == "ALBUM ARTIST") SetAlbumArtist(tag, StringListToVectorString(it->second));
else if (it->first == "ALBUM") tag.SetAlbum(it->second.front().to8Bit(true));
else if (it->first == "TITLE") tag.SetTitle(it->second.front().to8Bit(true));
else if (it->first == "TRACKNUMBER") tag.SetTrackNumber(it->second.front().toInt());
else if (it->first == "DISCNUMBER") tag.SetPartOfSet(it->second.front().toInt());
else if (it->first == "YEAR") tag.SetYear(it->second.front().toInt());
else if (it->first == "DATE") tag.SetYear(it->second.front().toInt());
else if (it->first == "GENRE") SetGenre(tag, StringListToVectorString(it->second));
else if (it->first == "COMMENT") tag.SetComment(it->second.front().to8Bit(true));
else if (it->first == "ENCODEDBY") {}
else if (it->first == "ENSEMBLE") {}
else if (it->first == "COMPILATION") tag.SetCompilation(it->second.front().toInt() == 1);
else if (it->first == "LYRICS") tag.SetLyrics(it->second.front().to8Bit(true));
else if (it->first == "REPLAYGAIN_TRACK_GAIN") tag.SetReplayGainTrackGain((int)(atof(it->second.front().toCString(true)) * 100 + 0.5));
else if (it->first == "REPLAYGAIN_ALBUM_GAIN") tag.SetReplayGainAlbumGain((int)(atof(it->second.front().toCString(true)) * 100 + 0.5));
else if (it->first == "REPLAYGAIN_TRACK_PEAK") tag.SetReplayGainTrackPeak((float)atof(it->second.front().toCString(true)));
else if (it->first == "REPLAYGAIN_ALBUM_PEAK") tag.SetReplayGainAlbumPeak((float)atof(it->second.front().toCString(true)));
else if (it->first == "MUSICBRAINZ_ARTISTID") tag.SetMusicBrainzArtistID(it->second.front().to8Bit(true));
else if (it->first == "MUSICBRAINZ_ALBUMARTISTID") tag.SetMusicBrainzAlbumArtistID(it->second.front().to8Bit(true));
else if (it->first == "MUSICBRAINZ_ALBUMID") tag.SetMusicBrainzAlbumID(it->second.front().to8Bit(true));
else if (it->first == "MUSICBRAINZ_TRACKID") tag.SetMusicBrainzTrackID(it->second.front().to8Bit(true));
else if (it->first == "RATING")
{
// Vorbis ratings are a mess because the standard forgot to mention anything about them.
// If you want to see how emotive the issue is and the varying standards, check here:
// http://forums.winamp.com/showthread.php?t=324512
// The most common standard in that thread seems to be a 0-100 scale for 1-5 stars.
// So, that's what we'll support for now.
int iRating = it->second.front().toInt();
if (iRating > 0 && iRating <= 100)
tag.SetRating((iRating / 20) + '0');
}
else if (g_advancedSettings.m_logLevel == LOG_LEVEL_MAX)
CLog::Log(LOGDEBUG, "unrecognized XipComment name: %s", it->first.toCString(true));
}
return true;
}
示例5: Load
bool CMusicInfoTagLoaderApe::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art)
{
try
{
// retrieve the APE Tag info from strFileName
// and put it in tag
tag.SetURL(strFileName);
DVDPlayerCodec codec;
if (codec.Init(strFileName, 4096))
{
tag.SetDuration((int)(codec.m_TotalTime/1000));
codec.DeInit();
}
CAPEv2Tag myTag;
if (myTag.ReadTag((char*)strFileName.c_str())) // true to check ID3 tag as well
{
tag.SetTitle(myTag.GetTitle());
tag.SetAlbum(myTag.GetAlbum());
tag.SetArtist(myTag.GetArtist());
tag.SetAlbumArtist(myTag.GetAlbumArtist());
tag.SetGenre(myTag.GetGenre());
tag.SetTrackNumber(myTag.GetTrackNum());
tag.SetPartOfSet(myTag.GetDiscNum());
tag.SetComment(myTag.GetComment());
tag.SetLyrics(myTag.GetLyrics());
tag.SetMusicBrainzAlbumArtistID(myTag.GetMusicBrainzAlbumArtistID());
tag.SetMusicBrainzAlbumID(myTag.GetMusicBrainzAlbumID());
tag.SetMusicBrainzArtistID(myTag.GetMusicBrainzArtistID());
tag.SetMusicBrainzTrackID(myTag.GetMusicBrainzTrackID());
tag.SetMusicBrainzTRMID(myTag.GetMusicBrainzTRMID());
SYSTEMTIME dateTime;
ZeroMemory(&dateTime, sizeof(SYSTEMTIME));
dateTime.wYear = atoi(myTag.GetYear());
tag.SetRating(myTag.GetRating());
tag.SetReleaseDate(dateTime);
tag.SetLoaded();
return true;
}
}
catch (...)
{
CLog::Log(LOGERROR, "Tag loader ape: exception in file %s", strFileName.c_str());
}
tag.SetLoaded(false);
return false;
}
示例6: Load
bool CMusicInfoTagLoaderApe::Load(const CStdString& strFileName, CMusicInfoTag& tag)
{
try
{
// retrieve the APE Tag info from strFileName
// and put it in tag
tag.SetURL(strFileName);
CAPEv2Tag myTag;
if (myTag.ReadTag((char*)strFileName.c_str())) // true to check ID3 tag as well
{
tag.SetTitle(myTag.GetTitle());
tag.SetAlbum(myTag.GetAlbum());
tag.SetArtist(myTag.GetArtist());
tag.SetAlbumArtist(myTag.GetAlbumArtist());
tag.SetGenre(myTag.GetGenre());
tag.SetTrackNumber(myTag.GetTrackNum());
tag.SetPartOfSet(myTag.GetDiscNum());
tag.SetComment(myTag.GetComment());
tag.SetLyrics(myTag.GetLyrics());
SYSTEMTIME dateTime;
ZeroMemory(&dateTime, sizeof(SYSTEMTIME));
dateTime.wYear = atoi(myTag.GetYear());
tag.SetRating(myTag.GetRating());
tag.SetReleaseDate(dateTime);
tag.SetLoaded();
return true;
}
}
catch (...)
{
CLog::Log(LOGERROR, "Tag loader ape: exception in file %s", strFileName.c_str());
}
tag.SetLoaded(false);
return false;
}
示例7: switch
//.........这里部分代码省略.........
tag.SetAlbumArtist( dataWorkspace.get() );
break;
}
case g_DayAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
SYSTEMTIME dateTime;
dateTime.wYear = atoi( dataWorkspace.get() );
tag.SetReleaseDate( dateTime );
break;
}
case g_GenreAtomName:
{
// When a genre number is specified, we need to translate to a string for display..
// Note that AAC/iTunes genre numbers are the same as ID3 numbers, but are offset by 1.
const char* pGenre = ID3_V1GENRE2DESCRIPTION( (unsigned char)pMetaData[ 1 ] - 1 );
if ( pGenre )
{
tag.SetGenre( pGenre );
}
break;
}
case g_CompilationAtomName:
{
if (metaSize == 1)
m_isCompilation = *pMetaData == 1;
break;
}
case g_CommentAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
tag.SetComment( dataWorkspace.get() );
break;
}
case g_LyricsAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
tag.SetLyrics( dataWorkspace.get() );
break;
}
case g_CustomGenreAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
tag.SetGenre( dataWorkspace.get() );
break;
}
case g_TrackNumberAtomName:
{
tag.SetTrackNumber( pMetaData[ 3 ] );
break;
}
case g_DiscNumberAtomName:
{
tag.SetPartOfSet( pMetaData[ 3 ] );
break;
}
case g_CoverArtAtomName:
{
// This cover-art handling is pretty much what was in the old MP4 tag processing code..
// note that according to http://atomicparsley.sourceforge.net/mpeg-4files.html the type
// of image (PNG=14 or JPG=13) is contained in pMetadata[-5] but we currently don't use this.
m_thumbSize = metaSize;
delete[] m_thumbData;
m_thumbData = new BYTE[m_thumbSize];
if (m_thumbData)
memcpy(m_thumbData, pMetaData, metaSize);
break;
}
default:
break;
}
}
示例8: SetTagValueString
void CMusicInfoTagLoaderWMA::SetTagValueString(const CStdString& strFrameName, const CStdString& strValue, CMusicInfoTag& tag)
{
if (strFrameName == "WM/AlbumTitle")
{
tag.SetAlbum(strValue);
}
else if (strFrameName == "WM/AlbumArtist")
{
if (tag.GetAlbumArtist().IsEmpty()) tag.SetAlbumArtist(strValue);
}
else if (strFrameName == "Author")
{
// Multiple artists are stored in multiple "Author" tags we have get them
// separatly and merge them to our system
if (tag.GetArtist().IsEmpty())
tag.SetArtist(strValue);
else
tag.SetArtist(tag.GetArtist() + g_advancedSettings.m_musicItemSeparator + strValue);
}
else if (strFrameName == "WM/TrackNumber")
{
if (tag.GetTrackNumber() <= 0) tag.SetTrackNumber(atoi(strValue.c_str()));
}
else if (strFrameName == "WM/PartOfSet")
{
tag.SetPartOfSet(atoi(strValue.c_str()));
}
//else if (strFrameName=="WM/Track") // Old Tracknumber, should not be used anymore
else if (strFrameName == "WM/Year")
{
SYSTEMTIME dateTime;
dateTime.wYear = atoi(strValue.c_str());
tag.SetReleaseDate(dateTime);
}
else if (strFrameName == "WM/Genre")
{
// Multiple genres are stared in multiple "WM/Genre" tags we have to get them
// separatly and merge them to our system
if (tag.GetGenre().IsEmpty())
tag.SetGenre(strValue);
else
tag.SetGenre(tag.GetGenre() + g_advancedSettings.m_musicItemSeparator + strValue);
}
else if (strFrameName == "WM/Lyrics")
{
tag.SetLyrics(strValue);
}
//else if (strFrameName=="WM/DRM")
//{
// // File is DRM protected
// pwszValue;
//}
//else if (strFrameName=="WM/Codec")
//{
// pwszValue;
//}
//else if (strFrameName=="WM/BeatsPerMinute")
//{
// pwszValue;
//}
//else if (strFrameName=="WM/Mood")
//{
// pwszValue;
//}
//else if (strFrameName=="WM/RadioStationName")
//{
// pwszValue;
//}
//else if (strFrameName=="WM/RadioStationOwner")
//{
// pwszValue;
//}
}
示例9: if
//.........这里部分代码省略.........
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
SYSTEMTIME dateTime;
dateTime.wYear = atoi( dataWorkspace.get() );
tag.SetReleaseDate( dateTime );
break;
}
case g_GenreAtomName:
{
// When a genre number is specified, we need to translate to a string for display..
// Note that AAC/iTunes genre numbers are the same as ID3 numbers, but are offset by 1.
const char* pGenre = ID3_V1GENRE2DESCRIPTION( (unsigned char)pMetaData[ 1 ] - 1 );
if ( pGenre )
{
tag.SetGenre( pGenre );
}
break;
}
case g_CompilationAtomName:
{
if (metaSize == 1)
tag.SetCompilation(*pMetaData == 1);
break;
}
case g_CommentAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
tag.SetComment( dataWorkspace.get() );
break;
}
case g_LyricsAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
tag.SetLyrics( dataWorkspace.get() );
break;
}
case g_CustomGenreAtomName:
{
// We need to zero-terminate the string, which needs workspace..
auto_aptr<char> dataWorkspace( new char[ metaSize + 1 ] );
memcpy( dataWorkspace.get(), pMetaData, metaSize );
dataWorkspace[ metaSize ] = '\0';
tag.SetGenre( dataWorkspace.get() );
break;
}
case g_TrackNumberAtomName:
{
tag.SetTrackNumber( (unsigned char)pMetaData[ 3 ] );
break;
}
case g_DiscNumberAtomName:
{
tag.SetPartOfSet( (unsigned char)pMetaData[ 3 ] );
break;
}
case g_CoverArtAtomName:
{
// This cover-art handling is pretty much what was in the old MP4 tag processing code..
// note that according to http://atomicparsley.sourceforge.net/mpeg-4files.html the type
// of image (PNG=14 or JPG=13) is contained in pMetadata[-5]
std::string mimeType;
if (pMetaData[-5] == 13)
mimeType = "image/jpeg";
else if (pMetaData[-5] == 14)
mimeType = "image/png";
else
CLog::Log(LOGDEBUG, "Unknown art mimetype %d", pMetaData[-5]);
tag.SetCoverArtInfo(metaSize, mimeType);
if (art)
art->set((const uint8_t*)pMetaData, metaSize, mimeType);
break;
}
default:
break;
}
}
示例10: ParseXiphComment
bool CTagLoaderTagLib::ParseXiphComment(Ogg::XiphComment *xiph, EmbeddedArt *art, CMusicInfoTag& tag)
{
if (!xiph)
return false;
FLAC::Picture pictures[3];
const Ogg::FieldListMap& fieldListMap = xiph->fieldListMap();
for (Ogg::FieldListMap::ConstIterator it = fieldListMap.begin(); it != fieldListMap.end(); ++it)
{
if (it->first == "ARTIST") SetArtist(tag, StringListToVectorString(it->second));
else if (it->first == "ALBUMARTIST") SetAlbumArtist(tag, StringListToVectorString(it->second));
else if (it->first == "ALBUM ARTIST") SetAlbumArtist(tag, StringListToVectorString(it->second));
else if (it->first == "ALBUM") tag.SetAlbum(it->second.front().to8Bit(true));
else if (it->first == "TITLE") tag.SetTitle(it->second.front().to8Bit(true));
else if (it->first == "TRACKNUMBER") tag.SetTrackNumber(it->second.front().toInt());
else if (it->first == "DISCNUMBER") tag.SetPartOfSet(it->second.front().toInt());
else if (it->first == "YEAR") tag.SetYear(it->second.front().toInt());
else if (it->first == "DATE") tag.SetYear(it->second.front().toInt());
else if (it->first == "GENRE") SetGenre(tag, StringListToVectorString(it->second));
else if (it->first == "COMMENT") tag.SetComment(it->second.front().to8Bit(true));
else if (it->first == "ENCODEDBY") {}
else if (it->first == "ENSEMBLE") {}
else if (it->first == "COMPILATION") tag.SetCompilation(it->second.front().toInt() == 1);
else if (it->first == "LYRICS") tag.SetLyrics(it->second.front().to8Bit(true));
else if (it->first == "REPLAYGAIN_TRACK_GAIN") tag.SetReplayGainTrackGain((int)(atof(it->second.front().toCString(true)) * 100 + 0.5));
else if (it->first == "REPLAYGAIN_ALBUM_GAIN") tag.SetReplayGainAlbumGain((int)(atof(it->second.front().toCString(true)) * 100 + 0.5));
else if (it->first == "REPLAYGAIN_TRACK_PEAK") tag.SetReplayGainTrackPeak((float)atof(it->second.front().toCString(true)));
else if (it->first == "REPLAYGAIN_ALBUM_PEAK") tag.SetReplayGainAlbumPeak((float)atof(it->second.front().toCString(true)));
else if (it->first == "MUSICBRAINZ_ARTISTID") tag.SetMusicBrainzArtistID(StringListToVectorString(it->second));
else if (it->first == "MUSICBRAINZ_ALBUMARTISTID") tag.SetMusicBrainzAlbumArtistID(StringListToVectorString(it->second));
else if (it->first == "MUSICBRAINZ_ALBUMARTIST") SetAlbumArtist(tag, StringListToVectorString(it->second));
else if (it->first == "MUSICBRAINZ_ALBUMID") tag.SetMusicBrainzAlbumID(it->second.front().to8Bit(true));
else if (it->first == "MUSICBRAINZ_TRACKID") tag.SetMusicBrainzTrackID(it->second.front().to8Bit(true));
else if (it->first == "RATING")
{
// Vorbis ratings are a mess because the standard forgot to mention anything about them.
// If you want to see how emotive the issue is and the varying standards, check here:
// http://forums.winamp.com/showthread.php?t=324512
// The most common standard in that thread seems to be a 0-100 scale for 1-5 stars.
// So, that's what we'll support for now.
int iRating = it->second.front().toInt();
if (iRating > 0 && iRating <= 100)
tag.SetRating((iRating / 20) + '0');
}
else if (it->first == "METADATA_BLOCK_PICTURE")
{
const char* b64 = it->second.front().toCString();
std::string decoded_block = Base64::Decode(b64, it->second.front().size());
ByteVector bv(decoded_block.data(), decoded_block.size());
TagLib::FLAC::Picture* pictureFrame = new TagLib::FLAC::Picture(bv);
if (pictureFrame->type() == FLAC::Picture::FrontCover) pictures[0].parse(bv);
else if (pictureFrame->type() == FLAC::Picture::Other) pictures[1].parse(bv);
delete pictureFrame;
}
else if (it->first == "COVERART")
{
const char* b64 = it->second.front().toCString();
std::string decoded_block = Base64::Decode(b64, it->second.front().size());
ByteVector bv(decoded_block.data(), decoded_block.size());
pictures[2].setData(bv);
// Assume jpeg
if (pictures[2].mimeType().isEmpty())
pictures[2].setMimeType("image/jpeg");
}
else if (it->first == "COVERARTMIME")
{
pictures[2].setMimeType(it->second.front());
}
else if (g_advancedSettings.m_logLevel == LOG_LEVEL_MAX)
CLog::Log(LOGDEBUG, "unrecognized XipComment name: %s", it->first.toCString(true));
}
// Process the extracted picture frames; 0 = CoverArt, 1 = Other, 2 = COVERART/COVERARTMIME
for (int i = 0; i < 3; ++i)
if (pictures[i].data().size())
{
string mime = pictures[i].mimeType().toCString();
if (mime.find("image/") != 0)
continue;
TagLib::uint size = pictures[i].data().size();
tag.SetCoverArtInfo(size, mime);
if (art)
art->set((const uint8_t*)pictures[i].data().data(), size, mime);
break;
}
return true;
}