public void DoUpdateSimilarTrackInfo(TagInfoRequest request, List<Song> TagTracks) { GUIListItem item = null; { facadeSimilarTrackInfo.Clear(); for (int i = 0; i < TagTracks.Count; i++) { item = new GUIListItem(TagTracks[i].ToShortString()); item.Label = TagTracks[i].Artist + " - " + TagTracks[i].Title; //item.Label2 = " (" + GUILocalizeStrings.Get(931) + ": " + Convert.ToString(TagTracks[i].TimesPlayed) + ")"; //item.Label = TagTracks[i].Artist; //item.Label2 = TagTracks[i].Title; item.MusicTag = TagTracks[i].ToMusicTag(); facadeSimilarTrackInfo.Add(item); // display 3 items only if (facadeSimilarTrackInfo.Count == DISPLAY_LISTITEM_COUNT) { break; } } if (facadeSimilarTrackInfo.Count > 0) { if (LblBestSimilarTracks != null) { LblBestSimilarTracks.Label = GUILocalizeStrings.Get(33031) + TagTracks[0].Genre; LblBestSimilarTracks.Visible = true; } if (facadeAlbumInfo == null || facadeAlbumInfo.Count == 0) { // previously focus was set all the time // to maintain previous functionality set focus if // defauly skin control is present if (lblForceFocus != null) { GUIControl.FocusControl(GetID, ((int)ControlIDs.LIST_TAG_INFO)); } } } } }
/// <summary> /// Updates the "similar tags" info for the current track playing. /// The tag info is fetched asynchronously by adding a request onto the request queue of the AudioScrobblerUtils /// class. The response will be received via callback by a delegate (OnUpdateSimilarTrackInfoCompleted). /// </summary> private void UpdateSimilarTrackInfo() { string CurrentArtist = CleanTagString(CurrentTrackTag.Artist); string CurrentTrack = CleanTagString(CurrentTrackTag.Title); if (_doTrackTagLookups) { if (CurrentTrackTag == null) { return; } if (CurrentTrackTag.Artist == string.Empty || CurrentTrackTag.Title == string.Empty) { Log.Warn("GUIMusicPlayingNow: current tag invalid for tag info lookup. File: {0}", g_Player.CurrentFile); return; } if (LblBestSimilarTracks != null) { LblBestSimilarTracks.Visible = false; } TagInfoRequest request = new TagInfoRequest( CurrentArtist, CurrentTrack, true, false, true, new TagInfoRequest.TagInfoRequestHandler(OnUpdateSimilarTrackInfoCompleted) ); _lastTagRequest = request; InfoScrobbler.AddRequest(request); } }
public void OnUpdateSimilarTrackInfoCompleted(TagInfoRequest request, List<Song> TagTracks) { if (request.Equals(_lastTagRequest)) { GUIGraphicsContext.form.Invoke(new TagInfoCompletedDelegate(DoUpdateSimilarTrackInfo), new object[] {request, TagTracks}); } else { Log.Warn("NowPlaying.OnUpdateSimilarTrackInfoCompleted: unexpected response for request: {0}", request.Type); } }