private void StopPlugin() { configForm?.Close(); configForm = null; server?.Stop(); server = null; revisionManager?.Stop(); revisionManager = null; }
// receive event notifications from MusicBee // you need to set about.ReceiveNotificationFlags = PlayerEvents to receive all notifications, and not just the startup event public void ReceiveNotification(string sourceFileUrl, NotificationType type) { switch (type) { case NotificationType.PluginStartup: settings = LoadSettings(); try { string dataPath = mbApi.Setting_GetPersistentStoragePath(); using (XmlReader mbConfig = XmlReader.Create(Path.Combine(dataPath, "MusicBeeSettings.ini"), new XmlReaderSettings { IgnoreWhitespace = true })) { mbConfig.ReadToFollowing("TagArtworkScanFilter"); using (XmlReader filterReader = mbConfig.ReadSubtree()) { while (filterReader.Read()) { if (filterReader.NodeType == XmlNodeType.Text && mbConfig.Value != "*.*") { artworkPatterns.Add(mbConfig.Value); } } } }; } catch (Exception) { } mbTracks = new TrackList(); db = new DAAP.MusicBeeDatabase(settings.serverName, settings.optimisedMetadata); revisionManager = new MusicBeeRevisionManager(db); InitialiseServer(); break; case NotificationType.FileAddedToInbox: case NotificationType.FileAddedToLibrary: revisionManager.Notify(MusicBeeRevisionManager.NotificationType.FileAdded); break; case NotificationType.FileDeleted: revisionManager.Notify(MusicBeeRevisionManager.NotificationType.FileRemoved); break; case NotificationType.TagsChanged: revisionManager.Notify(MusicBeeRevisionManager.NotificationType.FileChanged); break; case NotificationType.LibrarySwitched: RestartServer(); break; default: break; } }