Exemple #1
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);
        }
    }
Exemple #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));
            }
        }
    }
    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");
        }
    }
Exemple #5
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();
        }
    }
Exemple #6
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));
            }
        }
    }
    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");
        }
    }
    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);
        }
    }
    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);
            }
        }
    }
Exemple #10
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;
        }
    }
Exemple #11
0
    public void updateHoverUI(PlaylistScript playlistScript)
    {
        this.playlistScript = playlistScript;

        FullTrack track = playlistScript.getFullTrack();

        if (track != null)
        {
            TimeSpan t = TimeSpan.FromMilliseconds(playlistScript.getFullTrack().DurationMs);

            FullTrack fullTrack = playlistScript.getFullTrack();

            string answer = string.Format("{0:D2}m:{1:D2}s",
                                          t.Minutes,
                                          t.Seconds);

            textPro.SetText(playlistScript.getPlaylistName()
                            + "\n" + "Length: " + answer + "\n" + fullTrack.Artists[0].Name
                            );
        }
        else
        {
            textPro.SetText(playlistScript.getPlaylistName());
        }
    }
    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);
                    }
                }
            }
        }
    }
    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");
        }
    }
Exemple #14
0
    public void InitializeUI(PlaylistScript playlistScript)
    {
        this.playlistScript = playlistScript;

        if (playlistScript.gameObject.tag == "song")
        {
            artistNameProText.text += playlistScript.playlistName;
            songNameProText.text    = "";
        }
        else if (playlistScript.gameObject.tag == "artist")
        {
            artistNameProText.text += playlistScript.getPlaylistName();
            songNameProText.text    = "";
            // descriptionProText.text += ("Popularity: " + playlistScript.fullArtist.Popularity + "/n" + " Genre: " + playlistScript.fullArtist.Genres[0]);
        }
        else if (playlistScript.gameObject.tag == "playlist")
        {
            artistNameProText.text += playlistScript.getPlaylistName();
            songNameProText.text    = "";

            if (playlistScript.getSimplePlaylist() != null)
            {
                descriptionProText.text += ("Playlist Owner: " + playlistScript.getSimplePlaylist().Owner.DisplayName);
            }
        }
        else
        {
            Debug.LogError("Could not initialize Vinyl UI, tag not found");
        }
    }
    IEnumerator Lerp(Collider collider)
    {
        Debug.LogError("Lerping");
        float t        = 0f;
        float duration = 2f;

        Vector3 startPostition = collider.transform.position;
        Vector3 endPostition   = disc.transform.position;

        Quaternion startRotation = collider.transform.rotation;
        Quaternion endRotation   = disc.transform.rotation;


        while (t < 1)
        {
            t += Time.deltaTime / duration;

            collider.transform.position = Vector3.Lerp(startPostition, endPostition, t);
            collider.transform.rotation = Quaternion.Lerp(startRotation, endRotation, t);

            yield return(null);
        }

        VinylScript    vinylScript    = collider.gameObject.GetComponent <VinylScript>();
        PlaylistScript playlistScript = vinylScript.playlistScript;

        playlistScript.PlaySomething();
    }
Exemple #16
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;
        }
    }
    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();
        }
    }
Exemple #18
0
    public void InstansiateVinylWorking(PlaylistScript playlistScript)
    {
        spawnedVinyl = Instantiate(vinyl, new Vector3(10, 2, 0), Quaternion.Euler(-90f, 0, 0));


        spawnedVinyl.GetComponent <VinylScript>().playlistScript = playlistScript;
        spawnedVinyl.GetComponent <VinylScript>().AnimateToPlayer(rightHandAnchor.transform.position + new Vector3(-0.5f, 0, 1.0f));
        spawnedVinyl.GetComponent <VinylScript>().InitializeUI(playlistScript);
    }
    private void InstansiateVinylWorking(RaycastHit hit, PlaylistScript playlistScript)
    {
        spawnedVinyl = Instantiate(vinyl, hit.transform.position + new Vector3(0, 0, -0.5f), Quaternion.Euler(-90f, 0, 0));


        spawnedVinyl.GetComponent <VinylScript>().playlistScript = playlistScript;
        // spawnedVinyl.GetComponent<VinylScript>().AnimateToPlayer(rightHandAnchor.transform.position + new Vector3(-0.5f, 0, 1.0f), ovrPlayerController.transform.rotation);
        spawnedVinyl.GetComponent <VinylScript>().AnimateToPlayer(ovrPlayerController.transform.position + spawnPosition2, ovrPlayerController.transform.rotation);
        spawnedVinyl.GetComponent <VinylScript>().InitializeUI(playlistScript);
    }
Exemple #20
0
    /// <summary>
    /// Logic for when a raycast line collides with a collider and and the input button is pressed
    /// </summary>
    void RayCastInput()
    {
        RaycastHit hit;

        if (Physics.Raycast(this.transform.position, this.transform.forward, out hit, raycastDistance))
        {
            Debug.Log(hit.transform.name);

            ResumePlayback resumePlayback = hit.transform.GetComponent <ResumePlayback>();
            PausePlayback  pausePlayback  = hit.transform.GetComponent <PausePlayback>();
            PlaylistScript playlistScript = hit.transform.GetComponent <PlaylistScript>();
            LeftHandUI     leftHandUI     = hit.transform.GetComponent <LeftHandUI>();

            if (hit.transform.gameObject.tag == "key")
            {
                Text text = hit.transform.gameObject.GetComponentInChildren <Text>();

                keyboardManagerScript.GenerateInput(text.text);
            }

            if (resumePlayback != null)
            {
                resumePlayback.ResumePlaybackFunction();
            }
            else if (leftHandUI != null)
            {
                leftHandUI.OnRayCastHit();
            }
            else if (pausePlayback != null)
            {
                pausePlayback.PausePlaybackFunction();
            }
            else if (playlistScript != null)
            {
                if (playOnClick)
                {
                    playlistScript.PlaySomething();
                }

                if (GameObject.FindWithTag("vinyl") != null)
                {
                    Destroy(GameObject.FindWithTag("vinyl"));
                }

                if (GameObject.FindWithTag("followCube") != null)
                {
                    Destroy(GameObject.FindWithTag("followCube"));
                }

                InstansiateVinylWorking(hit, playlistScript);

                Debug.Log("Spawning Vinyl");
            }
        }
    }
Exemple #21
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));
            }
        }
    }
    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));
            }
        }
    }
Exemple #23
0
 public PlaylistScriptData(PlaylistScript playlistScript)
 {
     playlistName        = playlistScript.playlistName;
     playlistURI         = playlistScript.playlistURI;
     artistName          = playlistScript.artistName;
     popularity          = playlistScript.popularity;
     ownerId             = playlistScript.ownerId;
     playlistId          = playlistScript.playlistId;
     albumId             = playlistScript.albumId;
     trackId             = playlistScript.trackId;
     artistId            = playlistScript.artistId;
     audioAnalysisCustom = playlistScript.audioAnalysisCustom;
 }
Exemple #24
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;
            }
        }
    }
Exemple #25
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));
            }
        }
    }
Exemple #26
0
    private void InstansiateVinyl(RaycastHit hit, PlaylistScript playlistScript)
    {
        Debug.Log("Instansiating at " + hit.transform.position + " plus " + spawnPosition);
        GameObject spawnedVinylContatainer = Instantiate(vinylContainer, hit.transform.position + new Vector3(0, 0, -0.5f), Quaternion.Euler(-90f, 0, 0));

        spawnedVinyl = spawnedVinylContatainer.transform.Find("vinyl").gameObject;
        GameObject spawnedFollowCube = spawnedVinylContatainer.transform.Find("Follow Cube").gameObject;

        spawnedFollowCube.GetComponent <FollowCubeScript>().playlistScript = playlistScript;

        spawnedVinyl.GetComponent <VinylScript>().playlistScript = playlistScript;
        spawnedVinylContatainer.GetComponent <VinylContainerScript>().AnimateToPlayer(rightHandAnchor.transform.position + new Vector3(-0.5f, 0, 1.0f));
        spawnedVinyl.GetComponent <VinylScript>().InitializeUI(playlistScript);
    }
Exemple #27
0
    public void GetRecommendations()
    {
        Debug.Log("GetRecommendations called");
        if (activeSeeds.Count > 0)
        {
            List <string> artistIds = new List <string>();
            List <string> trackIds  = new List <string>();

            foreach (var seed in activeSeeds)
            {
                PlaylistScript playlistScript = seed.GetComponent <VinylScript>().playlistScript;
                if (playlistScript.trackType == PlaylistScript.TrackType.artist)
                {
                    artistIds.Add(playlistScript.artistId);
                }
                else if (playlistScript.trackType == PlaylistScript.TrackType.playlist)
                {
                    FullPlaylist fullPlaylist = spotifyManagerScript.GetPlaylist(playlistScript.ownerId, playlistScript.playlistId);
                    artistIds.Add(fullPlaylist.Tracks.Items[0].Track.Artists[0].Id);
                }
                else if (playlistScript.trackType == PlaylistScript.TrackType.track)
                {
                    trackIds.Add(playlistScript.trackId);
                }
                else if (playlistScript.trackType == PlaylistScript.TrackType.album)
                {
                    FullAlbum fullAlbum = spotifyManagerScript.GetAlbum(playlistScript.albumId);
                    artistIds.Add(fullAlbum.Artists[0].Id);
                }
                else
                {
                    Debug.LogError("Unsupported track type");
                }
            }

            if (artistIds.Count != 0)
            {
                StartCoroutine(userRecommendations.LoadUserRecommendationsWithArtist(artistIds));
            }
            else if (trackIds.Count != 0)
            {
                StartCoroutine(userRecommendations.LoadUserRecommendationsWithTrack(trackIds));
            }
            else
            {
                Debug.LogError("Seed Id list is empty");
            }
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PlaylistScript playlistScript = (PlaylistScript)target;

        if (GUILayout.Button("Play Track"))
        {
            playlistScript.PlaySomething();
        }

        if (GUILayout.Button("Spawn Vinyl"))
        {
            playlistScript.SpawnVinyl();
        }
    }
Exemple #29
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.tag == "vinyl")
        {
            Debug.Log("Vinyl entering recommenderSeed");

            collider.gameObject.transform.Find("Canvas").gameObject.SetActive(false);

            StartCoroutine(Lerp(collider));

            recommenderDeckScript.activeSeeds.Add(collider.gameObject);

            PlaylistScript playlistScript = collider.gameObject.GetComponent <VinylScript>().playlistScript;

            seedText.text = playlistScript.playlistName;
        }
    }
    void OnTriggerExit(Collider collider)
    {
        if (collider.gameObject.tag == "vinyl")
        {
            collider.gameObject.transform.Find("Canvas").gameObject.SetActive(true);

            Debug.Log("Vinyl exiting recommenderSeed");

            recommenderDeckScript.activeSeeds.Remove(collider.gameObject);

            seedText.text = "Add seed";

            PlaylistScript playlistScript = collider.gameObject.GetComponent <VinylScript>().playlistScript;

            playlistScript.inRecommender = false;
        }
    }