Exemplo n.º 1
0
        public Song(JObject jo)
        {
            if (jo == null)
            {
                return;
            }

            UInt32 id;

            UInt32.TryParse(jo["id"].ToString(), out id);
            Id = id;

            int duration;

            Int32.TryParse(jo["duration"].ToString(), out duration);
            Duration = duration;

            Name = jo["name"].ToString();

            var isQualityExist = SongQuality.isQualityExist(jo);

            if (isQualityExist != QualityType.Invalid)
            {
                //判断音质优先级
                SongQuality quality = null;
                if ((isQualityExist & QualityType.H) == QualityType.H)
                {
                    var jQuality = (JObject)jo["hMusic"];
                    quality = new SongQuality(jQuality);
                }

                if (quality == null & (isQualityExist & QualityType.M) == QualityType.M)
                {
                    var jQuality = (JObject)jo["mMusic"];
                    quality = new SongQuality(jQuality);
                }

                if (quality == null & (isQualityExist & QualityType.L) == QualityType.L)
                {
                    var jQuality = (JObject)jo["lMusic"];
                    quality = new SongQuality(jQuality);
                }

                Quality = quality;
            }
        }