コード例 #1
0
ファイル: DaapServer.cs プロジェクト: graemephi/musicbee-daap
 private void StopPlugin()
 {
     configForm?.Close();
     configForm = null;
     server?.Stop();
     server = null;
     revisionManager?.Stop();
     revisionManager = null;
 }
コード例 #2
0
ファイル: DaapServer.cs プロジェクト: graemephi/musicbee-daap
        // 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;
            }
        }