Esempio n. 1
0
    public async void Start()
    {
        _loadParent.gameObject.SetActive(true);
        _headerParent.gameObject.SetActive(false);
        _songsParent.gameObject.SetActive(false);

        SpotifyClient client = SpotifyService.Instance.GetSpotifyClient();

        if (client != null)
        {
            Paging <SavedTrack> paging = await client.Library.GetTracks();

            // Load all saved tracks
            _allSavedTracks = await S4UUtility.GetAllOfPagingAsync(client, paging, MaximumLength) as List <SavedTrack>;

            // Only show cwer
            if (_allSavedTracks.Count > MaximumLength)
            {
                _allSavedTracks.RemoveRange(MaximumLength, (_allSavedTracks.Count - 1) - MaximumLength);
            }

            // Load current user to display creator
            PrivateUser profile = await SpotifyService.Instance.GetSpotifyClient().UserProfile.Current();

            _creator = profile.DisplayName;

            _dispatcher.Add(() =>
            {
                UpdateUI();
            });
        }
    }
Esempio n. 2
0
    protected override async void OnSpotifyConnectionChanged(SpotifyClient client)
    {
        base.OnSpotifyConnectionChanged(client);

        // Check if we have permission to access logged in user's playlists
        if (SpotifyService.Instance.AreScopesAuthorized(Scopes.PlaylistReadPrivate))
        {
            // Get first page from client
            Paging <SimplePlaylist> page = await client.Playlists.CurrentUsers();

            // Get rest of pages from utility function and set variable to run on main thread
            _allPlaylists = await S4UUtility.GetAllOfPagingAsync(client, page);

            _isPopulated = false;
        }
        else
        {
            Debug.LogError($"Not authorized to access '{Scopes.PlaylistReadPrivate}'");
        }
    }