public void UpdateUI(PlayerStateSendData playerState) { mMuteDuringVideosCheckbox.Checked = playerState.AutoMutingEnabled; mBgMusicNameLabel.Text = playerState.ActiveBgMusicTitle; //mMusicInfoLabel.Text = playerState.TrackName; _toolStripItemDict["play"].Visible = playerState.AllowPlay; _toolStripItemDict["like"].Visible = playerState.AllowLike; _toolStripItemDict["dislike"].Visible = playerState.AllowDislike; _toolStripItemDict["mute"].Visible = playerState.AllowMute; _toolStripItemDict["unmute"].Visible = playerState.AllowUnmute; _toolStripItemDict["stop"].Visible = playerState.AllowStop; _toolStripItemDict["pause"].Visible = playerState.AllowPause; _toolStripItemDict["nexttrack"].Visible = playerState.AllowNextTrack; _toolStripItemDict["prevtrack"].Visible = playerState.AllowPrevTrack; mBgMusicIcon.Image = MuteFmConfigUtil.GetImage(playerState.ActiveBgMusicId, 32); for (int i = 0; i < playerState.fgMusicTitles.Length; i++) { FgMusicInfoControl fgMusicControl; bool muted = (bool)playerState.fgMusicIsMuteds.GetValue(i); bool ignored = (bool)playerState.fgMusicIgnores.GetValue(i); long musicId = (long)playerState.fgMusicIds.GetValue(i); string name = (string)playerState.fgMusicTitles.GetValue(i); if (_fgControlDict.TryGetValue(musicId, out fgMusicControl)) { fgMusicControl.UpdateUI(name, muted, ignored); } else { fgMusicControl = FgMusicInfoControl.CreateFgMusicInfoControl(musicId, name, muted, ignored); mFgMusicSoundsGroupBox.Controls.Add(fgMusicControl); _fgControlDict[musicId] = fgMusicControl; } } // Remove controls that aren't active for (int i = mFgMusicSoundsGroupBox.Controls.Count - 1; i >= 0; i--) { if (mFgMusicSoundsGroupBox.Controls[i] is FgMusicInfoControl) { long musicId = ((FgMusicInfoControl)(mFgMusicSoundsGroupBox.Controls[i])).MusicId; bool found = false; for (int j = 0; j < playerState.fgMusicTitles.Length; j++) { if ((long)playerState.fgMusicIds.GetValue(j) == musicId) { found = true; break; } } if (!found) { mFgMusicSoundsGroupBox.Controls.RemoveAt(i); } } } }
private void UpdateBgMusicUI() { SoundPlayerInfo playerInfo = SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GetActiveBgMusic(); mBackgroundMusicName.Text = playerInfo.Name; this.mBgMusicIcon.Image = MuteFmConfigUtil.GetImage(playerInfo.Id, 16); }
private void mMusicInfoFileNameTextBox_TextChanged(object sender, EventArgs e) { string procname = GetProcName(this.mMusicInfoFileNameTextBox.Text); mDefaultsButton.Enabled = MuteFmConfigUtil.hasDefaults(procname); //this.mNoIgnoreAutomuteCheckbox.Checked = }
void webControl1_AddressChanged(object sender, Awesomium.Core.UrlEventArgs e) { this.mUrlText.Text = webControl1.Source.ToString(); if (webControl1.Source.ToString() == "about:blank") { return; } SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.MostRecentUrl = webControl1.Source.ToString(); MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); }
private void reloadIconsToolStripMenuItem_Click(object sender, EventArgs e) { WebServer.ClearOldEntries(DateTime.Now); for (int i = 0; i < SmartVolManagerPackage.BgMusicManager.MuteFmConfig.BgMusics.Length; i++) { MuteFmConfigUtil.GenerateIconImage(SmartVolManagerPackage.BgMusicManager.MuteFmConfig.BgMusics[i], false); } mBgMusicIcon.Image = MuteFmConfigUtil.GetImage(MuteFm.SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.Id, 32); }
private void showEditDialog(SoundPlayerInfo playerInfo, bool editable) { if (playerInfo != null) { MusicInfoEditForm form = new MusicInfoEditForm(playerInfo, editable); form.ShowDialog(); if (form.DialogResult == System.Windows.Forms.DialogResult.OK) { MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); } } }
private void mOkButton_Click(object sender, EventArgs e) { List <Hotkey> hotkeyList = new List <Hotkey>(); for (int i = 0; i < _hotkeyControls.Count; i++) { Hotkey hotkey = new Hotkey(_hotkeyControls[i].HotkeyName, _hotkeyControls[i].HotkeyEnabled, _hotkeyControls[i].HotkeyKey); hotkeyList.Add(hotkey); } SmartVolManagerPackage.BgMusicManager.MuteFmConfig.Hotkeys = hotkeyList.ToArray(); MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); this.Close(); }
private void noneToolStripMenuItem_Click(object sender, EventArgs e) { if (!noneToolStripMenuItem.Checked) { noneToolStripMenuItem.Checked = true; growlToolStripMenuItem.Checked = false; systrayBalloonsToolStripMenuItem.Checked = false; SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.ShowBalloonNotifications = false; MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); GrowlInstallHelper.GrowlInstallHelper.SetForceGrowl(false); } }
private void mDefaultsButton_Click(object sender, EventArgs e) { string procname = ""; if (mWebsiteRadioButton.Checked) { procname = this.mWebsiteUrlTextBox.Text.Trim().TrimEnd('/'); } else { procname = GetProcName(this.mMusicInfoFileNameTextBox.Text); } if (MuteFmConfigUtil.hasDefaults(procname)) { SoundPlayerInfo tempMusicInfo = new SoundPlayerInfo(); if (mWebsiteRadioButton.Checked) { tempMusicInfo.UrlOrCommandLine = procname; } else { tempMusicInfo.UrlOrCommandLine = mMusicInfoFileNameTextBox.Text; } if (this.mWebsiteRadioButton.Checked) { MuteFmConfigUtil.InitDefaultsWeb(tempMusicInfo); } else { MuteFmConfigUtil.InitDefaultsProcess(tempMusicInfo, procname); } _commands["OnLoad"] = tempMusicInfo.OnLoadCommand; _commands["Play"] = tempMusicInfo.PlayCommand; _commands["Pause"] = tempMusicInfo.PauseCommand; _commands["PrevTrack"] = tempMusicInfo.PrevSongCommand; _commands["NextTrack"] = tempMusicInfo.NextSongCommand; _commands["Like"] = tempMusicInfo.LikeCommand; _commands["Dislike"] = tempMusicInfo.DislikeCommand; _commands["Stop"] = tempMusicInfo.StopCommand; MessageBox.Show(this, "Defaults loaded.", Constants.ProgramName); mCommandsListbox_SelectedIndexChanged(null, null); } else { MessageBox.Show(this, "No defaults", Constants.ProgramName); // should never see this } }
public PlayerForm() { InitializeComponent(); this.Text = MuteFm.Constants.ProgramName; aboutToolStripMenuItem.Text = "About " + MuteFm.Constants.ProgramName + "..."; Panel statusPanel = new Panel(); statusPanel.Dock = DockStyle.Bottom; statusPanel.Height = 20; statusPanel.BackColor = Color.White; this.Controls.Add(statusPanel); mStatusLabel = new Label(); mStatusLabel.BorderStyle = BorderStyle.FixedSingle; mStatusLabel.Text = "Status:"; mStatusLabel.Dock = DockStyle.Fill; statusPanel.Controls.Add(mStatusLabel); this.runOnStartupToolStripMenuItem.Checked = MuteFmConfigUtil.IsLoadedOnStartup(); this.playMusicOnStartupToolStripMenuItem.Checked = SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.PlayMusicOnStartup; this.notifyAboutProgramUpdatesToolStripMenuItem.Checked = SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.NotifyAboutUpdates; this.notifyWhenNoMusicToPlayToolStripMenuItem.Checked = SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.NotifyWhenNoMusicToPlay; this.growlToolStripMenuItem.Checked = GrowlInstallHelper.GrowlInstallHelper.GetForceGrowl(); this.systrayBalloonsToolStripMenuItem.Checked = !this.growlToolStripMenuItem.Checked && SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.ShowBalloonNotifications; this.noneToolStripMenuItem.Checked = (!growlToolStripMenuItem.Checked) && (!systrayBalloonsToolStripMenuItem.Checked); //mToolStrip.Items.Add("Send To Chrome", null, new EventHandler(mAlwaysOnTopToolStripButton_Click)); // TODO: also for other browsers addToolStripItem("mute", new EventHandler(mMuteButton_Click)); addToolStripItem("unmute", new EventHandler(mUnmuteButton_Click)); addToolStripItem("prevtrack", new EventHandler(mPrevTrackButton_Click)); addToolStripItem("play", new EventHandler(mPlayButton_Click)); addToolStripItem("pause", new EventHandler(mPauseButton_Click)); addToolStripItem("nexttrack", new EventHandler(mNextTrackButton_Click)); addToolStripItem("like", new EventHandler(mLikeButton_Click)); addToolStripItem("dislike", new EventHandler(mDislikeButton_Click)); addToolStripItem("stop", new EventHandler(mStopButton_Click)); mBgMusicToolStrip.Renderer = new CleanToolStripRenderer(); //MusicResumeSoonControl resumeSoon = new MusicResumeSoonControl(); //mFgMusicSoundsGroupBox.Controls.Add(resumeSoon); }
private void mDeleteButton_Click(object sender, EventArgs e) { if ((mSoundTree.SelectedNode != null) && (mSoundTree.SelectedNode.Tag != null)) { if (long.Parse((string)mSoundTree.SelectedNode.Tag) == SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GetActiveBgMusic().Id) { MessageBox.Show(this, "Cannot delete current background music.", Constants.ProgramName); return; } MuteFmConfigUtil.RemoveBgMusic(long.Parse((string)mSoundTree.SelectedNode.Tag), SmartVolManagerPackage.BgMusicManager.MuteFmConfig); MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); refresh(); } }
public static void ShowSite(string title, string url) { OnOperation(Operation.Stop); MuteFm.SoundPlayerInfo bgm = new MuteFm.SoundPlayerInfo(); bgm.IsWeb = true; bgm.UrlOrCommandLine = url; bgm.Name = title; // TODO: get title as well and then show domain: title or something similar (like in mutetab) bgm.Id = -1; MuteFmConfigUtil.GenerateIconImage(bgm, false); SmartVolManagerPackage.BgMusicManager.ActiveBgMusic = bgm; SmartVolManagerPackage.BgMusicManager.BgMusicPids = new int[0]; OnOperation(Operation.Show); }
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); }
private void runOnStartupToolStripMenuItem_Click(object sender, EventArgs e) { runOnStartupToolStripMenuItem.Checked = !runOnStartupToolStripMenuItem.Checked; MuteFmConfigUtil.ToggleLoadOnStartup(runOnStartupToolStripMenuItem.Checked); }
public MusicInfoEditForm(SoundPlayerInfo playerInfo, bool editable) { InitializeComponent(); this.Text = Constants.ProgramName + " - " + "Edit Sound Player Info"; #if NOAWE mWebsiteRadioButton.Text += " (Requires mute.fm+)"; #endif if (playerInfo == null) { this.Text = Constants.ProgramName + " - Add Sound Info"; _musicInfo = new SoundPlayerInfo(); #if !NOAWE _musicInfo.IsWeb = true; mWebsiteRadioButton.Checked = true; mProgramRadioButton.Enabled = true; mWebsiteRadioButton.Enabled = true; #else _musicInfo.IsWeb = false; mWebsiteRadioButton.Enabled = false; mProgramRadioButton.Enabled = true; mProgramRadioButton.Checked = true; mWebsiteRadioButton_CheckedChanged_1(null, null); #endif this.mIgnoreAutomuteCheckbox.Checked = false; this.mIgnoreAutomuteCheckbox.Visible = !_musicInfo.IsWeb; mStopIfMutedTooLongCheckbox.Checked = true; _commands["OnLoad"] = ""; _commands["Play"] = ""; _commands["Pause"] = ""; _commands["PrevTrack"] = ""; _commands["NextTrack"] = ""; _commands["Like"] = ""; _commands["Dislike"] = ""; _commands["Stop"] = ""; } else { _musicInfo = playerInfo; mWebsiteRadioButton.Checked = _musicInfo.IsWeb; mProgramRadioButton.Checked = !_musicInfo.IsWeb; mIgnoreAutomuteCheckbox.Visible = !_musicInfo.IsWeb; mWebsiteRadioButton_CheckedChanged_1(null, null); bool ignoreForAutomute = false; SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict.TryGetValue(GetProcName(_musicInfo.UrlOrCommandLine), out ignoreForAutomute); this.mIgnoreAutomuteCheckbox.Checked = ignoreForAutomute; mStopIfMutedTooLongCheckbox.Checked = playerInfo.KillAfterAutoMute; _commands["OnLoad"] = _musicInfo.OnLoadCommand; _commands["Play"] = _musicInfo.PlayCommand; _commands["Pause"] = _musicInfo.PauseCommand; _commands["PrevTrack"] = _musicInfo.PrevSongCommand; _commands["NextTrack"] = _musicInfo.NextSongCommand; _commands["Like"] = _musicInfo.LikeCommand; _commands["Dislike"] = _musicInfo.DislikeCommand; _commands["Stop"] = _musicInfo.StopCommand; mIcon.Image = MuteFmConfigUtil.GetImage(_musicInfo.Id, 16); } if (!editable) { foreach (Control control in this.Controls) { if ((string)control.Tag != "+") { control.Enabled = false; } } } }
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(); }
public void Init(MuteFmConfig muteTunesConfig, SoundPlayerInfo[] fgMusics) { TreeNode node; Object currentTag = null; UpdateBgMusicUI(); if (mSoundTree.SelectedNode != null) { currentTag = mSoundTree.SelectedNode.Tag; } ImageList imageList = new ImageList(); mSoundTree.ImageList = imageList; TreeNode[] children = new TreeNode[0]; imageList.Images.Add("0", UiCommands.mPlayerForm.Icon.ToBitmap()); mSoundTree.Nodes.Clear(); //TreeNode supportedWebNode = mSoundTree.Nodes.Add("Supported Web"); _activeSoundsNode = new TreeNode("Recent Sounds", 0, 0, children); mSoundTree.Nodes.Add(_activeSoundsNode); _favoritesNode = new TreeNode("Favorites", 0, 0, children); mSoundTree.Nodes.Add(_favoritesNode); for (int i = 0; i < fgMusics.Length; i++) { string fgMusicName = fgMusics[i].ShortProcessName; if (fgMusicName.Trim() == "") { fgMusicName = "System Sounds"; } node = new TreeNode(fgMusicName, i + 1, i + 1, children); _activeSoundsNode.Nodes.Add(node); node.Tag = fgMusics[i].ShortProcessName; imageList.Images.Add((string)(node.Tag), MuteFmConfigUtil.GetImage(fgMusics[i].Id, 16)); if ((string)node.Tag == (string)currentTag) { mSoundTree.SelectedNode = node; } } int j = 0; for (int i = 0; i < muteTunesConfig.BgMusics.Length; i++) { #if NOAWE // Don't show web-based music in the editor if (muteTunesConfig.BgMusics[i].IsWeb) { continue; } #endif node = new TreeNode(muteTunesConfig.BgMusics[i].Name, j + 1 + fgMusics.Length, j + 1 + fgMusics.Length, children); node.Tag = muteTunesConfig.BgMusics[i].Id.ToString(); _favoritesNode.Nodes.Add(node); Image image = MuteFmConfigUtil.GetImage(muteTunesConfig.BgMusics[i].Id, 16); if (image != null) { imageList.Images.Add((string)(node.Tag), image); } if ((string)node.Tag == (string)currentTag) { mSoundTree.SelectedNode = node; } j++; } _activeSoundsNode.ExpandAll(); _favoritesNode.ExpandAll(); }
private void notifyWhenNoMusicToPlayToolStripMenuItem_Click(object sender, EventArgs e) { notifyWhenNoMusicToPlayToolStripMenuItem.Checked = !notifyWhenNoMusicToPlayToolStripMenuItem.Checked; SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.NotifyWhenNoMusicToPlay = notifyWhenNoMusicToPlayToolStripMenuItem.Checked; MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); }
// Must be run within UI thread public static void InitUI(bool firstTime) { #if !NOAWE WebBgMusicForm = new MuteFm.UiPackage.WebBgMusicForm(); WebBgMusicForm.FormClosing += new FormClosingEventHandler(WebBgMusicForm_FormClosing); WebBgMusicForm.Resize += new EventHandler(WebBgMusicForm_Resize); //WebBgMusicForm.Show(); #endif _notificationType = new NotificationType("MUTEFM_NOTIFICATION", "mute.fm notification"); _growl = new GrowlConnector(); _growl.NotificationCallback += new GrowlConnector.CallbackEventHandler(growl_notification_callback); _growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText; // set to ease debugging // OLDNOTIFY TopForm.Instance.Show(); //UiPackage.UiCommands.SetNotification(Constants.ProgramName + " started (expires " + Constants.GetExpirationDateString() + ")", false); UiPackage.UiCommands.SetNotification(Constants.ProgramName + " started", false); if (SmartVolManagerPackage.BgMusicManager.MuteFmConfig.Hotkeys == null) { MuteFmConfigUtil.LoadDefaultHotkeys(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); } if (SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.SoundPollIntervalInS == 0) { SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.SoundPollIntervalInS = MuteFmConfig.SoundPollIntervalDefault; } RegisterHotkeys(); UiPackage.UiCommands.UpdateUiForState(MuteFm.SmartVolManagerPackage.BgMusicManager.GetValidOperation(), false, false, true); mPlayerForm = new PlayerForm(); mPlayerForm.FormClosed += new FormClosedEventHandler(mPlayer_FormClosed); mPlayerForm.Init(false); // MuteApp.UiPackage.UiCommands.ShowPlayer(); if (firstTime) { System.ComponentModel.BackgroundWorker firstTimeWorker = new BackgroundWorker(); firstTimeWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(DoFirstTimeWork); firstTimeWorker.RunWorkerAsync(); #if !NOAWE UiPackage.UiCommands.ShowGettingStartedWizard(); #endif mPlayerForm.ToggleTopmost(true); } else { if (SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.PlayMusicOnStartup) { System.ComponentModel.BackgroundWorker firstTimeWorker = new BackgroundWorker(); firstTimeWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(delegate { SoundPlayerInfo playerInfo = (SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GetActiveBgMusic()); System.Threading.Thread.Sleep(2000); OnOperation(Operation.Play, playerInfo.AutoPlaysOnStartup, false); if (playerInfo.AutoPlaysOnStartup == false) { System.ComponentModel.BackgroundWorker firstTimeWorker2 = new BackgroundWorker(); firstTimeWorker2.DoWork += new System.ComponentModel.DoWorkEventHandler(delegate { //System.Threading.Thread.Sleep(5000); //todo OnOperation(Operation.Play); }); firstTimeWorker2.RunWorkerAsync(); } System.Threading.Thread.Sleep(1000); OnOperation(Operation.Minimize); }); firstTimeWorker.RunWorkerAsync(); } } System.Windows.Forms.Application.Run(MuteFm.UiPackage.WinSoundServerSysTray.Instance); }
private void mMuteDuringVideosCheckbox_CheckedChanged(object sender, EventArgs e) { SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.AutoMuteEnabled = mMuteDuringVideosCheckbox.Checked; MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); }
private void notifyAboutProgramUpdatesToolStripMenuItem_Click(object sender, EventArgs e) { notifyAboutProgramUpdatesToolStripMenuItem.Checked = !notifyAboutProgramUpdatesToolStripMenuItem.Checked; SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.NotifyAboutUpdates = notifyAboutProgramUpdatesToolStripMenuItem.Checked; MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); }
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();*/ } }
private void mWebsiteUrlTextBox_TextChanged(object sender, EventArgs e) { mDefaultsButton.Enabled = MuteFmConfigUtil.hasDefaults(mWebsiteUrlTextBox.Text); }
private void playMusicOnStartupToolStripMenuItem_Click(object sender, EventArgs e) { playMusicOnStartupToolStripMenuItem.Checked = !playMusicOnStartupToolStripMenuItem.Checked; SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.PlayMusicOnStartup = playMusicOnStartupToolStripMenuItem.Checked; MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig); }