Alxandr / SpotiFire

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

How to add a Track to a Playlist from a Search #7

Closed thematlin closed 13 years ago

thematlin commented 13 years ago

There seems to be an issue when adding a Track from a Search to a specific Playlist caused by collections expecting different types. A Search contains an IArray<ITrack> and adding Track to a IPlaylist requires a IPlaylistTrack. A code example to how it might work:

ITrack track = search.Tracks[position];
IPlaylist playlist = Playlist.GetById(playlistId);
playlist.Tracks.Add(track);
Alxandr commented 13 years ago

By the way, that should fix it, but I haven't been able to test (don't have that much time on my hands right now), you mind testing it for me?

thematlin commented 13 years ago

It seems to work nicely. There was some issues related to this where marshalling of the track pointer array wasn't working properly, I forked and pushed a fix. Not very familiar with Github yet so don't know how to "reference" the commit to this issue. But you want me to create a pull request?

Alxandr commented 13 years ago

Sure, please do.

thematlin commented 13 years ago

I'm still having some problems.. every now and then, haven't figured out exactly when, I get an exception in PlaylistTrack that says that key already exists in collection. I figure I'll try to fix that as well before doing a pull request. If that sounds allright with you?

Alxandr commented 13 years ago

This is probably a synchronization-issue. If you are able to solve it, that would be great. I'm guessing locking on the playlist is the way to go, but I'm not sure. Oh, and please create a new ticket for this, as it is a separate issue. Also, if you are able to fix it you should include a line containing "Fixes #" (without both " and <>). Your help at finding bugs and at developing is greatly appreciated btw.

thematlin commented 13 years ago

I am unable to reproduce this exception that I got. You still want me to create an issue?