private void UpdateUI() { if (_artist != null) { SetUIActive(true); if (_artistName != null) { _artistName.text = _artist.Name; } if (_icon != null) { // Update to target image size RectTransform rect = _icon.GetComponent <RectTransform>(); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, ImageSize.x); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ImageSize.y); SpotifyAPI.Web.Image lowestResImg = S4UUtility.GetLowestResolutionImage(_artist.Images); StartCoroutine(S4UUtility.LoadImageFromUrl(lowestResImg?.Url, (sprite) => { _icon.sprite = sprite; })); } } else { SetUIActive(false); } }
private void UpdateUI() { if (_playlist != null) { if (_nameText != null) { _nameText.text = _playlist.Name; } if (_creatorText != null) { _creatorText.text = "By " + _playlist.Owner.DisplayName; } if (_icon != null) { SpotifyAPI.Web.Image image = S4UUtility.GetLowestResolutionImage(_playlist.Images); if (image != null) { StartCoroutine(S4UUtility.LoadImageFromUrl(image.Url, (loadedSprite) => { _icon.sprite = loadedSprite; })); } } if (_playPlaylistBtn != null) { _playPlaylistBtn.onClick.AddListener(() => { SpotifyClient client = SpotifyService.Instance.GetSpotifyClient(); PlayerResumePlaybackRequest request = new PlayerResumePlaybackRequest { ContextUri = _playlist.Uri }; client.Player.ResumePlayback(request); }); } } }