/// <summary>
 /// Called when a playlist is added to the playlist container.
 /// When the playlist is fully loaded, the playlist is 'introduced', meaning events
 /// changing the meta-data of this playlist will be tracked.
 /// If no pending changes are present, the playlist will be stored.
 /// Also, every playlist that is added will have its state changes tracked.
 /// </summary>
 void AddPlaylist(SpotiFire.Playlist playlist)
 {
     lock (playlist) {
         //LogPlaylist(playlist, "added");
         if (playlist.IsFullyLoaded())
         {
             Introduce(playlist);
             if (!playlist.HasPendingChanges)
             {
                 CreateOrUpdate(playlist);
             }
         }
         playlist.StateChanged += playlist_StateChanged;
     }
 }
 /// <summary>
 /// Called when the state of a playlist changes.
 /// If the playlist is in the playlist container and fully loaded, it introduces the
 /// playlist if that has not happened before.
 /// If no pending changes are present and no update is in progress, the playlist
 /// will be stored / updated.
 /// </summary>
 void playlist_StateChanged(SpotiFire.Playlist sender, PlaylistEventArgs e)
 {
     lock (sender) {
         //LogPlaylist(sender, "state changed");
         if (this.IsInSession(sender) && sender.IsFullyLoaded())
         {
             if (!sender.IsKnown())
             {
                 Introduce(sender);
             }
             if (!sender.HasPendingChanges && !sender.IsUpdateInProgress())
             {
                 CreateOrUpdate(sender);
             }
         }
     }
 }