Example #1
0
        private void PlaylistManagerAdded(object sender, PlaylistManagers.EventArgsPlaylistManager e)
        {
            ModelPlaylistManager playlistManager = null;

            try
            {
                playlistManager = new ModelPlaylistManager(e.PlaylistManager, iEventProvider);
                playlistManager.EventPlaylistManagerInitialised += Initialised;
                playlistManager.EventSubscriptionError          += EventSubscriptionError;
                playlistManager.Open();
                lock (iLock)
                {
                    iPlaylistManagers.Add(e.PlaylistManager, playlistManager);
                }
            }
            catch (Exception)
            {
                // failed to create the playlist manager - a dodgy playlist manger shouldn't crash the application
                UserLog.WriteLine(string.Format("{0}: Failed to create playlist manager ({1}, {2})", DateTime.Now, e.PlaylistManager.Name, e.PlaylistManager.Device.Model));
            }
        }
Example #2
0
        private void PlaylistManagerRemoved(object sender, PlaylistManagers.EventArgsPlaylistManager e)
        {
            bool removed = false;
            ModelPlaylistManager pm;

            lock (iLock)
            {
                Assert.Check(iPlaylistManagers.ContainsKey(e.PlaylistManager));
                pm = iPlaylistManagers[e.PlaylistManager];
                pm.EventPlaylistManagerInitialised -= Initialised;
                pm.EventSubscriptionError          -= EventSubscriptionError;
                pm.Close();

                iPlaylistManagers.Remove(e.PlaylistManager);
                removed = iOpenPlaylistManagers.ContainsKey(e.PlaylistManager);
                iOpenPlaylistManagers.Remove(e.PlaylistManager);
                iMetadata.ChildCount = iOpenPlaylistManagers.Count;
            }

            if (removed && EventContentRemoved != null)
            {
                EventContentRemoved(this, new EventArgsContentRemoved(pm.Metadata[0].Id));
            }
        }