How to add a Track to a Playlist from a Search
thematlin opened this issue · comments
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);
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?
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?
Sure, please do.
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?
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.
I am unable to reproduce this exception that I got. You still want me to create an issue?