Пример #1
0
 private void UpdatePlaylistDetailsUI()
 {
     if (_playlist != null)
     {
         if (_headerParent)
         {
             _headerParent.gameObject.SetActive(true);
         }
         if (_headerImg != null)
         {
             SpotifyAPI.Web.Image image = S4UUtility.GetLowestResolutionImage(_playlist.Images, 300, 300);
             StartCoroutine(S4UUtility.LoadImageFromUrl(image?.Url, (loadedSprite) =>
             {
                 _headerImg.sprite = loadedSprite;
             }));
         }
         if (_headerTitle != null)
         {
             _headerTitle.text = _playlist.Name;
         }
         if (_headerDescription != null)
         {
             _headerDescription.text = _playlist.Description;
         }
         if (_headerDetails != null)
         {
             _headerDetails.text = $"{ _playlist.Owner.DisplayName} • {_playlist.Tracks.Total.Value} songs";
         }
         if (_headerType != null)
         {
             _headerType.text = _playlist.Type.ToUpper();
         }
     }
 }
Пример #2
0
 // Updates the left hand side of the player (Artwork, track name, artists)
 private void UpdatePlayerInfo(string trackName, string artistNames, string artUrl)
 {
     if (_trackName != null)
     {
         _trackName.text = trackName;
     }
     if (_artistsNames != null)
     {
         _artistsNames.text = artistNames;
     }
     if (_trackIcon != null)
     {
         // Load sprite from url
         if (string.IsNullOrEmpty(artUrl))
         {
             _trackIcon.sprite = null;
         }
         else
         {
             StartCoroutine(S4UUtility.LoadImageFromUrl(artUrl, (loadedSprite) =>
             {
                 _trackIcon.sprite = loadedSprite;
             }));
         }
     }
 }
Пример #3
0
    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);
        }
    }
Пример #4
0
 private void DownloadUpdateSprite(Image img, List <SpotifyAPI.Web.Image> images)
 {
     if (img != null && img.sprite == null)
     {
         SpotifyAPI.Web.Image icon = S4UUtility.GetLowestResolutionImage(images);
         if (icon != null)
         {
             StartCoroutine(S4UUtility.LoadImageFromUrl(icon.Url, (loadedSprite) =>
             {
                 _icon.sprite = loadedSprite;
             }));
         }
     }
 }
Пример #5
0
    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);
                });
            }
        }
    }