예제 #1
0
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            _mbApiInterface = new MusicBeeApiInterface();
            _mbApiInterface.Initialise(apiInterfacePtr);
            _about.PluginInfoVersion = PluginInfoVersion;
            _about.Name                     = "DiscordBee";
            _about.Description              = "Update your Discord Profile with the currently playing track";
            _about.Author                   = "Stefan Lengauer";
            _about.TargetApplication        = ""; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
            _about.Type                     = PluginType.General;
            _about.VersionMajor             = 3;  // your plugin version
            _about.VersionMinor             = 0;
            _about.Revision                 = 3;
            _about.MinInterfaceVersion      = MinInterfaceVersion;
            _about.MinApiRevision           = MinApiRevision;
            _about.ReceiveNotifications     = ReceiveNotificationFlags.PlayerEvents;
            _about.ConfigurationPanelHeight = 0; // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function

            var workingDir       = _mbApiInterface.Setting_GetPersistentStoragePath() + _about.Name;
            var settingsFilePath = $"{workingDir}\\{_about.Name}.settings";

            _imgurAssetCachePath = $"{workingDir}\\{_about.Name}-Imgur.cache";
            _imgurAlbum          = $"{workingDir}\\{_about.Name}-Imgur.album";

            _settings = Settings.GetInstance(settingsFilePath);
            _settings.SettingChanged += SettingChangedCallback;
            _settingsWindow           = new SettingsWindow(this, _settings);

            _discordClient.ArtworkUploadEnabled = _settings.UploadArtwork;
            _discordClient.DiscordId            = _settings.DiscordAppId;
            UpdateAssetManager(_imgurAssetCachePath, new ImgurUploader(_imgurAlbum, _settings.ImgurClientId));
            ToolStripMenuItem mainMenuItem = (ToolStripMenuItem)_mbApiInterface.MB_AddMenuItem($"mnuTools/{_about.Name}", null, null);

            mainMenuItem.DropDown.Items.Add("Uploader Health", null, ShowUploaderHealth);

            // Match least number of chars possible but min 1
            _layoutHandler = new LayoutHandler(new Regex("\\[([^[]+?)\\]"));

            _updateTimer.Elapsed  += UpdateTimerElapsedCallback;
            _updateTimer.AutoReset = false;
            _updateTimer.Stop();

            Debug.WriteLine(_about.Name + " loaded");

            return(_about);
        }
예제 #2
0
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            _mbApiInterface = new MusicBeeApiInterface();
            _mbApiInterface.Initialise(apiInterfacePtr);
            _about.PluginInfoVersion = PluginInfoVersion;
            _about.Name                     = "DiscordBee";
            _about.Description              = "Update your Discord Profile with the currently playing track";
            _about.Author                   = "Stefan Lengauer";
            _about.TargetApplication        = ""; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
            _about.Type                     = PluginType.General;
            _about.VersionMajor             = 1;  // your plugin version
            _about.VersionMinor             = 4;
            _about.Revision                 = 2;
            _about.MinInterfaceVersion      = MinInterfaceVersion;
            _about.MinApiRevision           = MinApiRevision;
            _about.ReceiveNotifications     = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);
            _about.ConfigurationPanelHeight = 0; // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function

            var settingsFilePath = _mbApiInterface.Setting_GetPersistentStoragePath() + _about.Name + "\\" + _about.Name + ".settings";

            _settings       = Settings.GetInstance(settingsFilePath);
            _settingsWindow = new SettingsWindow(this, _settings);

            _discordClient          = new DiscordRpcClient("409394531948298250");
            _discordClient.OnError += ErrorCallback;
            _discordClient.OnClose += DisconnectedCallback;
            _discordClient.SkipIdenticalPresence = true;
            _discordClient.Logger = new DebugLogger(LogLevel.Trace);
            _discordClient.Initialize();

            _discordPresence.Assets     = new Assets();
            _discordPresence.Party      = new Party();
            _discordPresence.Timestamps = new Timestamps();

            // Match least number of chars possible but min 1
            _layoutHandler = new LayoutHandler(new Regex("\\[(.+?)\\]"));

            Debug.WriteLine(_about.Name + " loaded");

            return(_about);
        }