public IEnumerator LoadSearchResults(SearchItem searchItem)
    {
        if (searchItem.Albums.Items.Count != 0)
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                string searchItemImageURL = searchItem.Albums.Items[i].Images[0].Url;

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

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

                WWW imageURLWWW = new WWW(searchItemImageURL);

                yield return(imageURLWWW);

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

                playlistScript.setPlaylistName(searchItem.Albums.Items[i].Name);
                playlistScript.setPlaylistURI(searchItem.Albums.Items[i].Uri);
                playlistScript.sprite    = Converter.ConvertWWWToSprite(imageURLWWW);
                playlistScript.trackType = PlaylistScript.TrackType.album;
                playlistScript.albumId   = searchItem.Albums.Items[i].Id;
            }
        }

        else
        {
            Debug.LogError("Empty results returned");
        }
    }
예제 #2
0
    public void LoadNewReleasesFromFile()
    {
        //    saveLoad.Load();

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            PlaylistScriptData playlistScriptLoadedData = saveLoad.savedNewReleases[i];

            PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

            Sprite sprite = saveLoad.QuickLoadSpriteFromFile("newReleasesSprite" + i);

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

            playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
            playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
            playlistScript.artistName = playlistScriptLoaded.artistName;
            playlistScript.sprite     = saveLoad.QuickLoadSpriteFromFile("newReleasesSprite" + i);
            playlistScript.albumId    = playlistScriptLoaded.albumId;
        }
    }
예제 #3
0
    public IEnumerator LoadRecentlyPlayed()
    {
        yield return(new WaitForSeconds(2));

        recentlyPlayed = spotifyManagerScript.GetRecentlyPlayed();

        if (recentlyPlayed == null || recentlyPlayed.Items.Count == 0)
        {
            Debug.LogError("recentlyPlayed is null/empty");
        }
        else
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                FullTrack fullTrack = spotifyManagerScript.GetTrack(recentlyPlayed.Items[i].Track.Id);

                string recentlyPlayedImageURL = null;

                if (fullTrack.Album.Images.Count != 0)
                {
                    recentlyPlayedImageURL = fullTrack.Album.Images[0].Url;
                }

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

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

                WWW imageURLWWW = null;

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

                    yield return(imageURLWWW);

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


                AudioAnalysis audioAnalysis = spotifyManagerScript.GetAudioAnalysis(recentlyPlayed.Items[i].Track.Id);

                playlistScript.setPlaylistName(recentlyPlayed.Items[i].Track.Name);
                playlistScript.trackType = PlaylistScript.TrackType.track;
                playlistScript.setPlaylistURI(recentlyPlayed.Items[i].Track.Uri);
                playlistScript.artistId      = recentlyPlayed.Items[i].Track.Artists[0].Id;
                playlistScript.trackId       = recentlyPlayed.Items[i].Track.Id;
                playlistScript.audioAnalysis = audioAnalysis;

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

                playlistScript.audioAnalysisCustom = new AudioAnalysisCustom(audioAnalysis);
                saveLoad.savedRecentlyPlayed.Add(new PlaylistScriptData(playlistScript));
            }
        }
    }
예제 #4
0
    public void LoadRecentlyPlayedFromFilePNG()
    {
        if (saveLoad.savedRecentlyPlayed != null && saveLoad.savedRecentlyPlayed.Count != 0)
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                PlaylistScriptData playlistScriptLoadedData = saveLoad.savedRecentlyPlayed[i];

                PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

                Texture2D texture = saveLoad.LoadTextureFromFilePNG("recentlyPlayed" + i + ".png");

                meshRenderers[i].material.mainTexture = texture;

                playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
                playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
                playlistScript.artistName          = playlistScriptLoaded.artistName;
                playlistScript.trackType           = PlaylistScript.TrackType.track;
                playlistScript.sprite              = Converter.ConvertTextureToSprite(texture);
                playlistScript.trackId             = playlistScriptLoaded.trackId;
                playlistScript.audioAnalysisCustom = playlistScriptLoaded.audioAnalysisCustom;
            }
        }
        else
        {
            Debug.LogError("savedRecentlyPlayed is null/empty");
        }
    }
    public IEnumerator loadStuff()
    {
        yield return(new WaitForSeconds(2));

        FeaturedPlaylists featuredPlaylists = spotifyManagerScript.GetFeaturedPlaylists();

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            string featuredPlaylistImageURL = featuredPlaylists.Playlists.Items[i].Images[0].Url;

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

            PlaylistScript playlistScript = meshRendererGameObject.GetComponent <PlaylistScript>();
            //  playlistScript.setPlaylistURI(featuredPlaylists.Playlists.Items[i].Uri);

            WWW imageURLWWW = new WWW(featuredPlaylistImageURL);

            yield return(imageURLWWW);

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

            playlistScript.setPlaylistName(featuredPlaylists.Playlists.Items[i].Name);
            playlistScript.setPlaylistURI(featuredPlaylists.Playlists.Items[i].Uri);
        }
    }
예제 #6
0
    public void LoadChartTracksFromFilePNG()
    {
        spotifyManager = GameObject.Find("SpotifyManager");

        saveLoad = spotifyManager.GetComponent <SaveLoad>();

        quads = GetChildGameObjectWithTag("song");

        meshRenderers = GetMeshRenderers(quads);

        csvReader = spotifyManager.GetComponent <CSVReader>();

        chartTracks = csvReader.chartTrackList;

        if (saveLoad.savedChartTracks != null && saveLoad.savedChartTracks.Count != 0)
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                if (chartTracks != null || chartTracks.Count != 0)
                {
                    ChartTrack chartTrack = (ChartTrack)chartTracks[i + 1];
                }
                else
                {
                    Debug.LogError("chartTracks is null/empty");
                }

                PlaylistScriptData playlistScriptLoadedData = saveLoad.savedChartTracks[i];

                PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

                Texture2D texture = saveLoad.LoadTextureFromFilePNG("chartTrack" + i + ".png");

                meshRenderers[i].material.mainTexture = texture;

                playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
                playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
                playlistScript.artistName          = playlistScriptLoaded.artistName;
                playlistScript.artistId            = playlistScriptLoaded.artistId;
                playlistScript.sprite              = Converter.ConvertTextureToSprite(texture);
                playlistScript.trackId             = playlistScriptLoaded.trackId;
                playlistScript.audioAnalysisCustom = playlistScriptLoaded.audioAnalysisCustom;

                Vector3 v = popCubes[i].transform.localScale;

                if (playlistScriptLoaded.streams != null)
                {
                    popCubes[i].transform.localScale = new Vector3(v.x, float.Parse(playlistScriptLoaded.streams) * streamsScaling, v.z);
                }
            }
        }
        else
        {
            Debug.LogError("savedChartTracks is empty/null");
        }
    }
예제 #7
0
    public IEnumerator loadFeaturedPlaylists()
    {
        yield return(new WaitForSeconds(2));

        FeaturedPlaylists featuredPlaylists = spotifyManagerScript.GetFeaturedPlaylists();

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            string featuredPlaylistImageURL = featuredPlaylists.Playlists.Items[i].Images[0].Url;

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

            if (meshRendererGameObject.tag != "back")
            {
                PlaylistScript playlistScript = meshRendererGameObject.GetComponent <PlaylistScript>();

                WWW imageURLWWW = new WWW(featuredPlaylistImageURL);

                yield return(imageURLWWW);

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

                playlistScript.setPlaylistName(featuredPlaylists.Playlists.Items[i].Name);
                playlistScript.setPlaylistURI(featuredPlaylists.Playlists.Items[i].Uri);
                playlistScript.setSimplePlaylist(featuredPlaylists.Playlists.Items[i]);
                playlistScript.sprite     = ConvertWWWToSprite(imageURLWWW);
                playlistScript.ownerId    = featuredPlaylists.Playlists.Items[i].Owner.Id;
                playlistScript.playlistId = featuredPlaylists.Playlists.Items[i].Id;

                saveLoad.SaveTextureToFilePNG(ConvertWWWToTexture(imageURLWWW), "featuredPlaylist" + i + ".png");
                saveLoad.savedFeaturedPlaylists.Add(new PlaylistScriptData(playlistScript));
            }
        }
    }
예제 #8
0
    public IEnumerator loadNewAlbumReleases()
    {
        yield return(new WaitForSeconds(2));

        NewAlbumReleases newAlbumReleases = spotifyManagerScript.GetNewAlbumReleases();

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            string featuredPlaylistImageURL = newAlbumReleases.Albums.Items[i].Images[0].Url;

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

            PlaylistScript playlistScript = meshRendererGameObject.GetComponent <PlaylistScript>();
            //  playlistScript.setPlaylistURI(featuredPlaylists.Playlists.Items[i].Uri);

            WWW imageURLWWW = new WWW(featuredPlaylistImageURL);

            yield return(imageURLWWW);

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

            playlistScript.setPlaylistName(newAlbumReleases.Albums.Items[i].Name);
            playlistScript.setPlaylistURI(newAlbumReleases.Albums.Items[i].Uri);
            playlistScript.albumId     = newAlbumReleases.Albums.Items[i].Id;
            playlistScript.simpleAlbum = newAlbumReleases.Albums.Items[i];
            playlistScript.sprite      = ConvertWWWToSprite(imageURLWWW);
            saveLoad.SaveTextureToFilePNG(ConvertWWWToTexture(imageURLWWW), "newReleases" + i + ".png");
            saveLoad.savedNewReleases.Add(new PlaylistScriptData(playlistScript));

            yield return(new WaitForSeconds(10));

            saveLoad.Save();
        }
    }
    public void LoadUserPlaylistsFromFilePNG()
    {
        if (saveLoad.savedUserPlaylists != null && saveLoad.savedUserPlaylists.Count != 0)
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                PlaylistScriptData playlistScriptLoadedData = saveLoad.savedUserPlaylists[i];

                PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

                Texture2D texture = saveLoad.LoadTextureFromFilePNG("userPlaylist" + i + ".png");

                meshRenderers[i].material.mainTexture = texture;

                playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
                playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
                playlistScript.artistName = playlistScriptLoaded.artistName;
                playlistScript.sprite     = Converter.ConvertTextureToSprite(texture);
                playlistScript.playlistId = playlistScriptLoaded.playlistId;
                playlistScript.ownerId    = playlistScriptLoaded.ownerId;
            }
        }
        else
        {
            Debug.LogError("savedUserPlaylists is empty/null");
        }
    }
예제 #10
0
    public IEnumerator LoadChartTracks()
    {
        yield return(new WaitForSeconds(2));

        if (chartTracks == null || chartTracks.Count == 0)
        {
            Debug.LogError("Chart tracks is null/empty");
        }
        else
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                //i+1 because first row is header names
                ChartTrack chartTrack = (ChartTrack)chartTracks[i + 1];
                FullTrack  fullTrack  = spotifyManagerScript.GetTrack(chartTrack.apiUrl);

                if (fullTrack.HasError())
                {
                    Debug.LogError(fullTrack.Error.Status);
                    Debug.LogError(fullTrack.Error.Message);
                }
                else
                {
                    string chartTrackImageURL = fullTrack.Album.Images[0].Url;

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

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

                    WWW imageURLWWW = new WWW(chartTrackImageURL);

                    yield return(imageURLWWW);

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

                    AudioAnalysis audioAnalysis = spotifyManagerScript.GetAudioAnalysis(fullTrack.Id);

                    playlistScript.setFullTrack(fullTrack);
                    playlistScript.setPlaylistName(fullTrack.Name);
                    playlistScript.setPlaylistURI(fullTrack.Uri);
                    playlistScript.artistId            = fullTrack.Artists[0].Id;
                    playlistScript.artistName          = fullTrack.Artists[0].Name;
                    playlistScript.sprite              = ConvertWWWToSprite(imageURLWWW);
                    playlistScript.audioAnalysis       = audioAnalysis;
                    playlistScript.audioAnalysisCustom = new AudioAnalysisCustom(audioAnalysis);
                    playlistScript.trackId             = fullTrack.Id;
                    playlistScript.streams             = chartTrack.streams;
                    saveLoad.SaveTextureToFilePNG(Converter.ConvertWWWToTexture(imageURLWWW), "chartTrack" + i + ".png");
                    saveLoad.savedChartTracks.Add(new PlaylistScriptData(playlistScript));

                    Vector3 v = popCubes[i].transform.localScale;

                    if (chartTrack.streams != null)
                    {
                        popCubes[i].transform.localScale = new Vector3(v.x, float.Parse(chartTrack.streams) * streamsScaling, v.z);
                    }
                }
            }
        }
    }
예제 #11
0
    public void LoadTopArtistsFromFilePNG()
    {
        meshRenderers  = GetComponentsInChildren <MeshRenderer>();
        spotifyManager = GameObject.Find("SpotifyManager");
        saveLoad       = spotifyManager.GetComponent <SaveLoad>();

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            PlaylistScriptData playlistScriptLoadedData = saveLoad.savedTopArtists[i];

            PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

            Texture2D texture = saveLoad.LoadTextureFromFilePNG("topArtist" + i + ".png");

            meshRenderers[i].material.mainTexture = texture;

            playlistScript.artistId = playlistScriptLoaded.artistId;
            playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
            playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
            playlistScript.artistName = playlistScriptLoaded.artistName;
            playlistScript.sprite     = ConvertTextureToSprite(texture);
        }
    }
예제 #12
0
    public void LoadTopTracksFromFile()
    {
        savedTopTracks = saveLoad.savedTopTracks;

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            PlaylistScriptData playlistScriptLoadedData = saveLoad.savedTopTracks[i];

            PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

            Sprite sprite = saveLoad.QuickLoadSpriteFromFile("topTrackSprite" + i);

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

            playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
            playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
            playlistScript.artistName          = playlistScriptLoaded.artistName;
            playlistScript.sprite              = sprite;
            playlistScript.trackId             = playlistScriptLoaded.trackId;
            playlistScript.audioAnalysisCustom = playlistScriptLoaded.audioAnalysisCustom;
        }
    }
예제 #13
0
    public IEnumerator loadTopTracks()
    {
        yield return(new WaitForSeconds(2));

        usersTopTracks = spotifyManagerScript.GetUsersTopTracks();
        if (usersTopTracks == null || usersTopTracks.Items.Count == null)
        {
            Debug.LogError("usersTopTracks is null/empty");
        }
        else
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                string featuredPlaylistImageURL = usersTopTracks.Items[i].Album.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(usersTopTracks.Items[i].Name);
                playlistScript.setPlaylistURI(usersTopTracks.Items[i].Uri);
                playlistScript.setFullTrack(usersTopTracks.Items[i]);
                playlistScript.audioAnalysis = spotifyManagerScript.GetAudioAnalysis(usersTopTracks.Items[i].Id);
                playlistScript.sprite        = ConvertWWWToSprite(imageURLWWW);
            }
        }
    }
    public IEnumerator loadTopTracks()
    {
        yield return(new WaitForSeconds(2));

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

                if (usersTopTracks.Items[i].Album.Images.Count != 0)
                {
                    topTrackImageURL = usersTopTracks.Items[i].Album.Images[0].Url;
                }

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

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

                WWW imageURLWWW = null;

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

                    yield return(imageURLWWW);

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

                AudioAnalysis audioAnalysis = spotifyManagerScript.GetAudioAnalysis(usersTopTracks.Items[i].Id);

                playlistScript.setPlaylistName(usersTopTracks.Items[i].Name);
                playlistScript.setPlaylistURI(usersTopTracks.Items[i].Uri);
                playlistScript.setFullTrack(usersTopTracks.Items[i]);
                playlistScript.audioAnalysis = audioAnalysis;

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

                playlistScript.trackId             = usersTopTracks.Items[i].Id;
                playlistScript.audioAnalysisCustom =
                    new AudioAnalysisCustom(audioAnalysis);
                saveLoad.savedTopTracks.Add(new PlaylistScriptData(playlistScript));
            }
            // yield return new WaitForSeconds(saveLoad.saveTime);
            // saveLoad.Save();
        }
    }
예제 #15
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));
            }
        }
    }
예제 #16
0
    public IEnumerator LoadUserPlaylists()
    {
        yield return(new WaitForSeconds(2));

        Paging <SimplePlaylist> usersPlaylists = spotifyManagerScript.GetUsersPlayists();

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

                if (usersPlaylists.Items[i].Images.Count != 0)
                {
                    userPlaylistImageURL = usersPlaylists.Items[i].Images[0].Url;
                }

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

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

                WWW imageURLWWW = null;

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

                    yield return(imageURLWWW);

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


                playlistScript.setPlaylistName(usersPlaylists.Items[i].Name);
                playlistScript.setPlaylistURI(usersPlaylists.Items[i].Uri);
                playlistScript.ownerId    = usersPlaylists.Items[i].Owner.Id;
                playlistScript.playlistId = usersPlaylists.Items[i].Id;

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

                saveLoad.savedUserPlaylists.Add(new PlaylistScriptData(playlistScript));
            }
        }
    }
예제 #17
0
    public IEnumerator loadNewAlbumReleases()
    {
        yield return(new WaitForSeconds(2));

        NewAlbumReleases newAlbumReleases = spotifyManagerScript.GetNewAlbumReleases();

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

                if (newAlbumReleases.Albums.Items[i].Images.Count != 0)
                {
                    newAlbumReleasesURL = newAlbumReleases.Albums.Items[i].Images[0].Url;
                }

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

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

                WWW imageURLWWW = null;

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

                    yield return(imageURLWWW);

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


                playlistScript.setPlaylistName(newAlbumReleases.Albums.Items[i].Name);
                playlistScript.setPlaylistURI(newAlbumReleases.Albums.Items[i].Uri);
                playlistScript.albumId     = newAlbumReleases.Albums.Items[i].Id;
                playlistScript.simpleAlbum = newAlbumReleases.Albums.Items[i];

                if (imageURLWWW != null)
                {
                    playlistScript.sprite = ConvertWWWToSprite(imageURLWWW);
                    saveLoad.SaveTextureToFilePNG(ConvertWWWToTexture(imageURLWWW), "newReleases" + i + ".png");
                }
                saveLoad.savedNewReleases.Add(new PlaylistScriptData(playlistScript));
            }
        }
    }
예제 #18
0
    public IEnumerator LoadUserRecommendationsWithTrack(List <string> ids)
    {
        Recommendations recommendations = spotifyManagerScript.GetRecommendationsWithTrack(ids);

        if (recommendations == null || recommendations.Tracks.Count == 0)
        {
            Debug.LogError("recommendations is null/empty");
        }
        else
        {
            for (int i = 0; i < meshRenderers.Length; i++)
            {
                FullTrack fullTrack = spotifyManagerScript.GetTrack(recommendations.Tracks[i].Id);

                string recommendationsImageURL = null;

                if (fullTrack.Album.Images.Count != 0)
                {
                    recommendationsImageURL = fullTrack.Album.Images[0].Url;
                }

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

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

                WWW imageURLWWW = null;

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

                    yield return(imageURLWWW);

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

                playlistScript.setPlaylistName(fullTrack.Name);
                playlistScript.setPlaylistURI(fullTrack.Uri);

                if (imageURLWWW != null)
                {
                    playlistScript.www    = imageURLWWW;
                    playlistScript.sprite = Converter.ConvertWWWToSprite(imageURLWWW);
                }

                playlistScript.trackId   = fullTrack.Id;
                playlistScript.artistId  = fullTrack.Artists[0].Id;
                playlistScript.trackType = PlaylistScript.TrackType.track;
            }
        }
    }
예제 #19
0
    public IEnumerator LoadUsersFollowedArtists()
    {
        yield return(new WaitForSeconds(2));

        Paging <SimplePlaylist> usersPlaylists = spotifyManagerScript.GetUsersPlayists();

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

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

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

                WWW imageURLWWW = new WWW(userPlaylistImageURL);

                yield return(imageURLWWW);

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

                playlistScript.setPlaylistName(usersPlaylists.Items[i].Name);
                playlistScript.setPlaylistURI(usersPlaylists.Items[i].Uri);
                playlistScript.sprite = ConvertWWWToSprite(imageURLWWW);
                saveLoad.SaveTextureToFilePNG(Converter.ConvertWWWToTexture(imageURLWWW), "userFollowedArtist" + i + ".png");
                saveLoad.savedUserFollowedArtists.Add(new PlaylistScriptData(playlistScript));
                Debug.Log("user followed artist running " + i);
            }
        }

        yield return(new WaitForSeconds(10));

        saveLoad.Save();
    }
예제 #20
0
    public void LoadNewReleasesFromFilePNG()
    {
        for (int i = 0; i < meshRenderers.Length; i++)
        {
            PlaylistScriptData playlistScriptLoadedData = saveLoad.savedNewReleases[i];

            PlaylistScript playlistScriptLoaded = new PlaylistScript(playlistScriptLoadedData);

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

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

            Texture2D texture = saveLoad.LoadTextureFromFilePNG("newReleases" + i + ".png");

            meshRenderers[i].material.mainTexture = texture;

            playlistScript.setPlaylistName(playlistScriptLoaded.playlistName);
            playlistScript.setPlaylistURI(playlistScriptLoaded.playlistURI);
            playlistScript.artistName = playlistScriptLoaded.artistName;
            playlistScript.sprite     = ConvertTextureToSprite(texture);
            playlistScript.albumId    = playlistScriptLoaded.albumId;
        }
    }
예제 #21
0
    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));
            }
        }
    }
    public IEnumerator LoadUserRecommendationsWithTrack(List <string> ids)
    {
        Recommendations recommendations = spotifyManagerScript.GetRecommendationsWithTrack(ids);

        for (int i = 0; i < meshRenderers.Length; i++)
        {
            FullTrack fullTrack = spotifyManagerScript.GetTrack(recommendations.Tracks[i].Id);

            string recommendationsImageURL = fullTrack.Album.Images[0].Url;

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

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

            WWW imageURLWWW = new WWW(recommendationsImageURL);

            yield return(imageURLWWW);

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

            playlistScript.setPlaylistName(fullTrack.Name);
            playlistScript.setPlaylistURI(fullTrack.Uri);
        }
    }