Beispiel #1
0
 // MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down)
 public void Close(PluginCloseReason reason)
 {
     _timer.Stop();
     Control.FromHandle(_mbApiInterface.MB_GetWindowHandle()).Invoke(new Action(() =>
     {
         _frmLyrics?.Dispose();
         _frmLyrics = null;
     }));
 }
Beispiel #2
0
        /// <inheritdoc/>
        public void Invoke(MethodInvoker invoker)
        {
            var hwnd = _api.MB_GetWindowHandle();
            var mb   = (Form)Control.FromHandle(hwnd);

            mb.Invoke(invoker);
        }
Beispiel #3
0
        /// <inheritdoc/>
        public LastfmStatus ChangeStatus(string action)
        {
            var hwnd = _api.MB_GetWindowHandle();
            var mb   = (Form)Control.FromHandle(hwnd);

            if (action.Equals("toggle", StringComparison.OrdinalIgnoreCase))
            {
                if (GetLfmStatus() == LastfmStatus.Love || GetLfmStatus() == LastfmStatus.Ban)
                {
                    return((LastfmStatus)mb.Invoke(new Func <LastfmStatus>(SetLfmNormalStatus)));
                }

                return((LastfmStatus)mb.Invoke(new Func <LastfmStatus>(SetLfmLoveStatus)));
            }

            if (action.Equals("love", StringComparison.OrdinalIgnoreCase))
            {
                return((LastfmStatus)mb.Invoke(new Func <LastfmStatus>(SetLfmLoveStatus)));
            }

            if (action.Equals("ban", StringComparison.OrdinalIgnoreCase))
            {
                return((LastfmStatus)mb.Invoke(new Func <LastfmStatus>(SetLfmLoveBan)));
            }

            return(GetLfmStatus());
        }
Beispiel #4
0
        private void updateTaskbarProgress()
        {
            float currentPos = mbApiInterface.Player_GetPosition();
            float totalTime  = mbApiInterface.NowPlaying_GetDuration();

            completedPercentage = currentPos / totalTime * 100;


            TaskbarProgress.SetValue(mbApiInterface.MB_GetWindowHandle(), completedPercentage, 100);
        }
        /// <summary>
        /// Called by MusicBee whenever it is loading the plugin whether at startup or when enabling the plugin.
        /// The pointer parameter should be copied to a <c>MusicBeeApiInterface</c> structure.
        /// </summary>
        /// <param name="apiInterfacePtr">Pointer to a <c>MusicBeeApiInterface</c> object</param>
        /// <returns></returns>
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            MbApiInterface = new MusicBeeApiInterface();
            MbApiInterface.Initialise(apiInterfacePtr);

            ReencodedFilesStorage = MbApiInterface.Setting_GetPersistentStoragePath() + "iTunesSync";
            if (!Directory.Exists(ReencodedFilesStorage))
            {
                Directory.CreateDirectory(ReencodedFilesStorage);
            }

            MbForm = (Form)Form.FromHandle(MbApiInterface.MB_GetWindowHandle());

            OpenMenu = MbApiInterface.MB_AddMenuItem(
                "mnuTools/" + Text.L("Open iTunes Sync"),
                Text.L("Opens iTunes to begin sync"),
                ToggleItunesOpenedAndClosed);

            return(Info);
        }