本文整理汇总了C#中TagLib.GetFirstField方法的典型用法代码示例。如果您正苦于以下问题:C# TagLib.GetFirstField方法的具体用法?C# TagLib.GetFirstField怎么用?C# TagLib.GetFirstField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagLib
的用法示例。
在下文中一共展示了TagLib.GetFirstField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRatingAndPlayCount
// Scans the file for ogg rating/playcount tags as defined by the Quod Libet standard
// If a Banshee tag is found, it is given priority.
// If a Banshee tag is not found, the last rating/playcount tags found are used
public static void GetRatingAndPlayCount(TagLib.Ogg.XiphComment xiphtag,
out int rating, out int playcount)
{
rating = -1;
playcount = 0;
bool howlerRatingDone = false, howlerPlaycountDone = false, mediaMonkeyFormat = false;
string ratingRaw = "", playcountRaw = "";
foreach (string fieldname in xiphtag)
{
if (!howlerRatingDone)
{
if (fieldname.StartsWith(RatingPrefix, StringComparison.OrdinalIgnoreCase))
{
ratingRaw = xiphtag.GetFirstField(fieldname);
string ratingCreator = fieldname.Substring(RatingPrefix.Length);
if (String.Compare(ratingCreator, HowlerName, StringComparison.OrdinalIgnoreCase) == 0)
{
// We made this rating, consider it authoritative.
howlerRatingDone = true;
// Don't return -- we might not have seen a playcount yet.
}
}
else if (String.Compare(fieldname, MediaMonkeyRatingField, StringComparison.OrdinalIgnoreCase) == 0)
{
ratingRaw = xiphtag.GetFirstField(fieldname);
mediaMonkeyFormat = true;
}
}
else if (!howlerPlaycountDone &&
fieldname.StartsWith(PlaycountPrefix, StringComparison.OrdinalIgnoreCase))
{
playcountRaw = xiphtag.GetFirstField(fieldname);
string playcountCreator = fieldname.Substring(PlaycountPrefix.Length);
if (string.Compare(playcountCreator, HowlerName, StringComparison.OrdinalIgnoreCase) == 0)
{
// We made this playcount, consider it authoritative.
howlerPlaycountDone = true;
// Don't return -- we might not have seen a rating yet.
}
}
}
if (!string.IsNullOrEmpty(ratingRaw))
{
if (howlerRatingDone || mediaMonkeyFormat)
rating = int.Parse(ratingRaw, CultureInfo.InvariantCulture);
else
{
int bansheeRating = OggToBanshee(ratingRaw);
rating = bansheeRating == 0 ? -1 : bansheeRating * 5;
}
}
if (!string.IsNullOrEmpty(playcountRaw))
{
playcount = int.Parse(playcountRaw, CultureInfo.InvariantCulture);
}
}