Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

Cannot save playlist #71

Closed alustrement closed 7 years ago

alustrement commented 7 years ago

Hi, I cannot find how to save adding/removing a track into an existing playlist. I proceed this way, no error, but no changes on my playlist. Any idea ? public async Task AddPlaylistTrackAsync(string playlistUri, Track track) { var session = await GetSessionAsync(); var link = session.GetLink(playlistUri); var playlist = await link.AsPlaylist(); playlist.Tracks.Add(track); }

Alxandr commented 7 years ago

Hi. This project is on hiatus until the new libspority is released from spotify. That being said, I have successfully added tracks to playlists before, so it at least did work at some point. @NeoLegends @ChrisBrandhorst anyone of you have any ideas?

brianavid commented 7 years ago

I no longer use SpotiFire for browsing - the (deprecated) underlying libspotify is too limited for current needs. So I have switched to using the WebApi.

But when I did use SpotiFire, the code I used (that worked fine) is:

    async Task AddTrackToPlayListAsync(
        string name,
        Track track)
    {
        Playlist playlist;
        if (!Playlists.ContainsKey(name))
        {
            playlist = await((await SpotifySession.Session.PlaylistContainer).Playlists.Create(name));
            await BuildPlayLists();
        }
        else
        {
            playlist = await playlists[name];
        }

        if (!playlist.Tracks.Contains(track))
        {
            playlist.Tracks.Add(track);
        }

        await BuildPlayLists();
    }

Note that Playlists is a static Dictionary mapping of name to Playlist, which is constructed by BuildPlayLists(). So it doesn't look that different from what you are doing!

alustrement commented 7 years ago

Thanks, but I have the same behavior, so I moved on to the webapi too!