Beispiel #1
0
    public IEnumerator LoadUsersFollowedArtists()
    {
        yield return(new WaitForSeconds(2));

        FollowedArtists followedArtists = spotifyManagerScript.GetUsersFollowedArtists();

        if (followedArtists == null || followedArtists.Artists.Items.Count == 0)
        {
            Debug.LogError("followedArtists is null/empty");
        }
        else
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                string followedArtistsImageURL = null;

                if (followedArtists.Artists.Items[i].Images.Count > 0)
                {
                    followedArtistsImageURL = followedArtists.Artists.Items[i].Images[0].Url;
                }

                GameObject meshRendererGameObject = meshRenderers[i].transform.gameObject;

                PlaylistScript playlistScript = meshRendererGameObject.GetComponent <PlaylistScript>();

                WWW imageURLWWW = null;

                if (followedArtistsImageURL != null)
                {
                    imageURLWWW = new WWW(followedArtistsImageURL);

                    yield return(imageURLWWW);

                    meshRenderers[i].material.mainTexture = imageURLWWW.texture;
                }

                playlistScript.setPlaylistName(followedArtists.Artists.Items[i].Name);
                playlistScript.setPlaylistURI(followedArtists.Artists.Items[i].Uri);
                playlistScript.fullArtist = followedArtists.Artists.Items[i];
                SeveralTracks artistTopTracks = spotifyManagerScript.GetArtistsTopTracks(followedArtists.Artists.Items[i].Id);
                playlistScript.audioAnalysisCustom = new AudioAnalysisCustom(spotifyManagerScript.GetAudioAnalysis(artistTopTracks.Tracks[0].Id));

                if (imageURLWWW != null)
                {
                    playlistScript.sprite = ConvertWWWToSprite(imageURLWWW);
                    saveLoad.SaveTextureToFilePNG(Converter.ConvertWWWToTexture(imageURLWWW), "userFollowedArtist" + i + ".png");
                }

                playlistScript.artistId = followedArtists.Artists.Items[i].Id;
                saveLoad.savedUserFollowedArtists.Add(new PlaylistScriptData(playlistScript));
            }
        }
    }
    private void playArtist()
    {
        //just plays the artists top song
        if (artistId != "")
        {
            script = spotifyManager.GetComponent <Spotify>();
            SeveralTracks artistTopTracks = script.GetArtistsTopTracks(artistId);

            if (artistTopTracks != null)
            {
                script.PlaySongUri(artistTopTracks.Tracks[0].Uri);
            }
        }
        else
        {
            Debug.LogError("artistId is empty");
        }
    }
Beispiel #3
0
    public IEnumerator Test_Spotify_GetArtistsTopTracks()
    {
        Spotify spotify = new Spotify();

        spotify.privateProfile         = new PrivateProfile();
        spotify.privateProfile.Country = "IE";

        spotify.TestSetup();

        //Vince Staples
        string artistId = "68kEuyFKyqrdQQLLsmiatm";

        SeveralTracks artistTopTracks = spotify.GetArtistsTopTracks(artistId);

        yield return(null);

        Debug.Log(artistTopTracks.Tracks[0].Name);

        Assert.IsFalse(artistTopTracks.HasError());
    }
    public IEnumerator loadTopArtists()
    {
        yield return(new WaitForSeconds(2));

        usersTopArtists = spotifyManagerScript.GetUsersTopArtists();
        if (usersTopArtists == null)
        {
            Debug.LogError("usersTopArtists is null");
        }
        else
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                string featuredPlaylistImageURL = usersTopArtists.Items[i].Images[0].Url;

                GameObject meshRendererGameObject = meshRenderers[i].transform.gameObject;

                PlaylistScript playlistScript = meshRendererGameObject.GetComponent <PlaylistScript>();

                WWW imageURLWWW = new WWW(featuredPlaylistImageURL);

                yield return(imageURLWWW);

                meshRenderers[i].material.mainTexture = imageURLWWW.texture;

                playlistScript.setPlaylistName(usersTopArtists.Items[i].Name);
                playlistScript.setPlaylistURI(usersTopArtists.Items[i].Uri);
                playlistScript.fullArtist = usersTopArtists.Items[i];
                playlistScript.artistId   = usersTopArtists.Items[i].Id;
                playlistScript.sprite     = ConvertWWWToSprite(imageURLWWW);
                SeveralTracks artistTopTracks = spotifyManagerScript.GetArtistsTopTracks(usersTopArtists.Items[i].Id);
                playlistScript.audioAnalysisCustom = new AudioAnalysisCustom(spotifyManagerScript.GetAudioAnalysis(artistTopTracks.Tracks[0].Id));
                saveLoad.SaveTextureToFilePNG(ConvertWWWToTexture(imageURLWWW), "topArtist" + i + ".png");
                saveLoad.savedTopArtists.Add(new PlaylistScriptData(playlistScript));
            }
        }
    }