Beispiel #1
0
        private SoundPlayerInfo makeSelectedAFavorite()
        {
            bool            found             = false;
            SoundPlayerInfo selectedSoundInfo = getRecentByName((string)mSoundTree.SelectedNode.Tag);
            SoundPlayerInfo playerInfo        = selectedSoundInfo;

            if (selectedSoundInfo != null)
            {
                // Determine if a favorite already exists for this and if so select it instead of adding a new favorite.
                int len = _favoritesNode.Nodes.Count;
                for (int i = 0; i < len; i++)
                {
                    long musicId = long.Parse((string)_favoritesNode.Nodes[i].Tag);
                    playerInfo = SmartVolManagerPackage.BgMusicManager.FindPlayerInfo(musicId);
                    if (playerInfo != null)
                    {
                        if (playerInfo.UrlOrCommandLine.ToLower() == selectedSoundInfo.UrlOrCommandLine.ToLower())
                        {
                            this.mSoundTree.SelectedNode = _favoritesNode.Nodes[i];
                            found = true;
                            break;
                        }
                    }
                }

                if (found)
                {
                    //MessageBox.Show("Already exists as a favorite.");
                }
                else
                {
                    selectedSoundInfo.Name = mSoundTree.SelectedNode.Text;
                    MuteFmConfigUtil.AddSoundPlayerInfo(selectedSoundInfo, SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
                }
            }
            return(playerInfo);
        }
Beispiel #2
0
        private void mOkButton_Click(object sender, EventArgs e)
        {
            if (mMusicInfoNameTextBox.Text.Trim() == "")
            {
                MessageBox.Show(this, "Error: Name not set.");
                return;
            }
            if ((!mWebsiteRadioButton.Checked) && (!System.IO.File.Exists(mMusicInfoFileNameTextBox.Text.Trim())))
            {
                MessageBox.Show(this, "File not found.  Please enter full path and do not include quotes.", Constants.ProgramName);
                return;
            }

            // Update ignoreforautomute
            if (!mWebsiteRadioButton.Checked)
            {
                bool wasIgnoreForAutomute;
                SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict.TryGetValue(GetProcName(_musicInfo.UrlOrCommandLine), out wasIgnoreForAutomute);
                if ((wasIgnoreForAutomute) && (!mIgnoreAutomuteCheckbox.Checked))
                {
                    // Remove it
                    string procname = GetProcName(_musicInfo.UrlOrCommandLine);
                    SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict.Remove(procname);
                    MuteFmConfigUtil.InitIgnoreForAutoMute(SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict, SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
                }
                else if (((!wasIgnoreForAutomute) && (mIgnoreAutomuteCheckbox.Checked)) && (mIgnoreAutomuteCheckbox.Visible = true))
                {
                    // Add it
                    string procname = GetProcName(mMusicInfoFileNameTextBox.Text);
                    SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict[procname] = true;
                    MuteFmConfigUtil.InitIgnoreForAutoMute(SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict, SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
                }
            }

            _musicInfo.IsWeb = mWebsiteRadioButton.Checked;
            _musicInfo.Name  = this.mMusicInfoNameTextBox.Text;

            if (_musicInfo.IsWeb)
            {
                _musicInfo.UrlOrCommandLine = this.mWebsiteUrlTextBox.Text.Trim();
                _musicInfo.CommandLineArgs  = "";
            }
            else
            {
                _musicInfo.UrlOrCommandLine = this.mMusicInfoFileNameTextBox.Text.Trim();
                _musicInfo.CommandLineArgs  = this.mProgramArgumentsTextBox.Text;
            }

            if (this.Text == Constants.ProgramName + " - Add Sound Info")
            {
                MuteFmConfigUtil.AddSoundPlayerInfo(_musicInfo, SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
            }

            _musicInfo.OnLoadCommand   = _commands["OnLoad"];
            _musicInfo.PlayCommand     = _commands["Play"];
            _musicInfo.PauseCommand    = _commands["Pause"];
            _musicInfo.PrevSongCommand = _commands["PrevTrack"];
            _musicInfo.NextSongCommand = _commands["NextTrack"];
            _musicInfo.LikeCommand     = _commands["Like"];
            _musicInfo.DislikeCommand  = _commands["Dislike"];
            _musicInfo.StopCommand     = _commands["Stop"];

            _musicInfo.KillAfterAutoMute = mStopIfMutedTooLongCheckbox.Checked;

            MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig);

            MuteFmConfigUtil.GenerateIconImage(_musicInfo, true);

            this.Close();
        }
Beispiel #3
0
        public static void OnOperation(long musicId, Operation op, string param, bool ignoreCommand, bool track)
        {
            if (Program.LicenseExpired == true)
            {
                return;
            }

            if (MuteFm.UiPackage.WinSoundServerSysTray.Instance == null)
            {
                return;
            }

            MuteFm.UiPackage.WinSoundServerSysTray.Instance.Invoke((System.Windows.Forms.MethodInvoker) delegate
            {
                if ((musicId == SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.Id) && ((op == Operation.Play) || (op == Operation.Unmute)))
                {
                    MuteFm.SmartVolManagerPackage.BgMusicManager.PerformOperation(musicId, Operation.ClearHistory, "", ignoreCommand);
                }

                if (op == Operation.Show)
                {
                    System.Threading.Thread.Sleep(250); // Ensure that window is shown after click sets focus to browser (if run in extension); was 750
                }
                // Queue up background music if a foreground sound is active
                // If user clicked play or unmute for bgmusic and music is automuted and countdown hasn't started, then note that user wants bgmusic and smartmute it but don't show fade messages or let it make sound [i.e. queue it up]
                if ((musicId == SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.Id) &&
                    (((op == Operation.Play) || (op == Operation.Unmute)) &&
                     (SmartVolManagerPackage.BgMusicManager.EffectiveSilenceDateTime == DateTime.MaxValue) &&
                     (!SmartVolManagerPackage.BgMusicManager.BgMusicHeard) &&
                     (SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.AutoMuteEnabled)))
                {
                    MuteFm.SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic = true;
                    MuteFm.SmartVolManagerPackage.BgMusicManager.PerformOperation(musicId, Operation.AutoMutedPlay, param, ignoreCommand);
                    return;
                }
                else
                {
                    int x = 0;
                    x++;
                }

                MuteFm.SmartVolManagerPackage.BgMusicManager.PerformOperation(musicId, op, param, ignoreCommand);

                if ((musicId == SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.Id) || (op == Operation.ChangeMusic))
                {
                    // Extra logic because we know user chose to perform the operation
                    switch (op)
                    {
                    case Operation.Play:
                        SmartVolManagerPackage.BgMusicManager.AutoMuted = false;     // TODO
                        MuteFm.SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic = true;
                        if (track)
                        {
                            TrackEvent("Play");
                        }
                        break;

                    case Operation.ChangeMusic:
                        SoundPlayerInfo playerInfo = SmartVolManagerPackage.BgMusicManager.FindPlayerInfo(musicId);
                        if (playerInfo != null)
                        {
                            SmartVolManagerPackage.BgMusicManager.UserMustClickPlay = false;     // reset it
                            if (playerInfo.Id <= 0)
                            {
                                MuteFmConfigUtil.AddSoundPlayerInfo(playerInfo, SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
                                //MixerWebSocketServerHelper.SendCommand("BGMUSICSITES", new GetBgMusicSiteSendData());
                            }

                            SmartVolManagerPackage.BgMusicManager.AlbumArtFileName = "";
                            SmartVolManagerPackage.BgMusicManager.TrackName        = "";

                            if (SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.IsWeb)     // Changed 8/16/13 to only do this if web-based
                            {
                                OnOperation(Operation.Stop);
                            }
                            else
                            {
                                OnOperation(Operation.Pause);
                            }

                            SmartVolManagerPackage.BgMusicManager.ActiveBgMusic  = playerInfo;
                            SmartVolManagerPackage.BgMusicManager.BgMusicPids    = new int[0];
                            SmartVolManagerPackage.BgMusicManager.BgMusicVolInit = false;
                            OnOperation(Operation.Play);
                            UiPackage.UiCommands.UpdateUiForState();

                            // If shows up as a fgmusic but not as a bgmusic, add to bgmusics and remove from fgmusic
                            if (MuteFmConfigUtil.FindBgMusic(playerInfo.UrlOrCommandLine, SmartVolManagerPackage.BgMusicManager.MuteFmConfig) == null)
                            {
                                long tempId = playerInfo.Id;
                                MuteFmConfigUtil.AddSoundPlayerInfo(playerInfo, SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
                                playerInfo.Id = tempId;

                                var fgMusicList = new List <MuteFm.SoundPlayerInfo>(SmartVolManagerPackage.BgMusicManager.FgMusics);
                                fgMusicList.Remove(playerInfo);
                                SmartVolManagerPackage.BgMusicManager.FgMusics = fgMusicList.ToArray();
                            }

                            // Save current music as new default
                            MuteFm.SmartVolManagerPackage.BgMusicManager.MuteFmConfig.ActiveBgMusicId = musicId;
                            MuteFmConfigUtil.Save(MuteFm.SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
                        }
                        break;

                    case Operation.Stop:
                        MuteFm.SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic = false;
                        if (_autoShowAfterPlayWorker != null)
                        {
                            _autoShowAfterPlayWorker.CancelAsync();
                            _autoShowAfterPlayWorker = null;
                        }
                        break;

                    case Operation.Pause:

                    case Operation.Mute:
                        MuteFm.SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic = false;

                        _autoShowAfterPlayWorker = new System.ComponentModel.BackgroundWorker();
                        _autoShowAfterPlayWorker.WorkerSupportsCancellation = true;
                        _autoShowAfterPlayWorker.DoWork += new DoWorkEventHandler(_isPausing_DoWork);
                        _autoShowAfterPlayWorker.RunWorkerAsync();

                        //MuteApp.SmartVolManagerPackage.BgMusicManager.PerformOperation(Operation.ClearHistory);
                        break;

                    case Operation.Unmute:
                        MuteFm.SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic = true;
                        break;

                    case Operation.Exit:
                        Exit();
                        break;
                    }
                }
            });
            if (op == Operation.Exit)
            {
                Exit();

                /*//UiPackage.UiCommands.SetTopText("Exiting mute.fm...", false);
                 * //System.Threading.Thread.Sleep(3000);
                 * WebBgMusicForm.Visible = false;
                 * WebBgMusicForm.Close();
                 * UiPackage.WinSoundServerSysTray.Instance.Close();
                 * Environment.Exit(0);
                 * //Application.Exit();*/
            }
        }