当前位置: 首页>>代码示例>>C#>>正文


C# TagLib.GetFirstField方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:gclark916,项目名称:Howler,代码行数:64,代码来源:OggTagger.cs


注:本文中的TagLib.GetFirstField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。