JoshLmao / Spotify4Unity

🎮🎵 Add the SpotifyAPI.NET library into Unity, enabling access to the Spotify Web API, allowing for control of Spotify and accessing the world of music
https://assetstore.unity.com/packages/tools/integration/spotify4unity-ui-tools-spotify-authorization-129028
MIT License
94 stars 8 forks source link

Load a pre-determined playlist? #34

Closed CrashCanHero closed 3 years ago

CrashCanHero commented 3 years ago

I'm working on a game where I want the music to come from a specific playlist I've already created, I can't find much in the wiki about loading a specific playlist so I was just wondering is I can even do that?

JoshLmao commented 3 years ago

Hi,

Apologies for the late reply. I suggest you update to v2.0. Then, you'll be able to simple do the following code for this to work.

SpotifyClient client = SpotifyService.Instance.GetSpotifyClient();
if (client != null)
{
    PlayerResumePlaybackRequest request = new PlayerResumePlaybackRequest()
    {
        ContextUri = fullPlaylist.Uri,
    };
    client.Player.ResumePlayback(request);
}