Reputation: 1505
I'm using the iTunes COM for retreiving information about the playlists that the user created. My goal is to add a new song to the library and then to the given playlist. That is what I have now:
public static void AddTrack(IITPlaylist playlist, PlaylistItem item, string path)
{
foreach (var track in AppClass.LibraryPlaylist.Tracks.Cast<IITTrack>().ToList())
{
if (track.Kind == ITTrackKind.ITTrackKindFile)
{
var fileTrack = track as IITFileOrCDTrack;
if (fileTrack?.Location == path || fileTrack?.Name == item.Title)
return;
}
}
AppClass.LibraryPlaylist.AddFile(path);
// Add new song to playlist here
}
However there is no proper documentation out there about adding songs to a playlist. The field IITPlaylist.Tracks
is read only otherwise I would add the song to this collection.
Upvotes: 1
Views: 433
Reputation: 21
it's a little bit late, but maybe it will be usefull for someone.
IITUserPlaylist playlist= (IITUserPlaylist)AppClass.LibrarySource.Playlists.ItemByName["PlaylistName"];
playlist.AddTrack(track);
Upvotes: 2