예제 #1
0
        /// <summary>
        /// Called when a page becomes the active page in a frame.
        /// </summary>
        /// <param name="e">An object that contains the event data.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.NavigationMode == NavigationMode.New)
            {
                this.TargetTrack = App.SelectedItem as Track;
                this.TargetTrack.Artist.AttemptNokiaLookup();
            }
        }
예제 #2
0
파일: Track.cs 프로젝트: srgb/Shuffler.fm
        /// <summary>
        /// Creates an Track from json.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <returns>An Track object</returns>
        internal static Track FromJson(JToken json)
        {
            JToken chartData = json["chart_data"];
            JToken images = json["images"];
            JToken links = json["links"];
            JToken metadata = json["metadata"];
            JToken post = json["post"];
            JToken site = json["site"];

            if (chartData.Type != JTokenType.Null && links.Type != JTokenType.Null && metadata.Type != JTokenType.Null && post.Type != JTokenType.Null && site.Type != JTokenType.Null && images.Type != JTokenType.Null && metadata["artist"].Type != JTokenType.Null)
            {
                JToken artist = metadata["artist"];
                Track track = new Track()
                {
                    Name = metadata.Value<string>("title"),
                    Artist = Artist.FromJson(artist),
                    FeatureCount = chartData.Value<int>("feature_count"),
                    Post = Post.FromJson(post),
                    Site = Site.FromJson(site),
                    ShufflerLink = new Uri(links.Value<string>("player_url"))
                };

                if (images["240x240"].Type != JTokenType.Null)
                {
                    track.Thumb240 = new Uri(images["240x240"].Value<string>("url"));
                }

                return track;
            }
            else
            {
                return null;
            }
        }