public static void OnRestartMP(int windowId) { var dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { return; } dlgYesNo.SetHeading(927); dlgYesNo.SetLine(1, "Settings changed!"); dlgYesNo.SetLine(2, "Do you want to restart MediaPortal?"); dlgYesNo.DoModal(windowId); if (!dlgYesNo.IsConfirmed) { return; } using (Profile.Settings xmlreader = new MPSettings()) { if (xmlreader.GetValueAsBool("general", "hidetaskbar", false)) { Win32API.EnableStartBar(true); Win32API.ShowStartBar(true); } } Log.Info("Settings: OnRestart - prepare for restart!"); File.Delete(Config.GetFile(Config.Dir.Config, "mediaportal.running")); Log.Info("Settings: OnRestart - saving settings..."); Profile.Settings.SaveCache(); DisposeDBs(); VolumeHandler.Dispose(); Log.Info("Main: OnSuspend - Done"); var restartScript = new Process { EnableRaisingEvents = false, StartInfo = { WorkingDirectory = Config.GetFolder(Config.Dir.Base), FileName = Config.GetFile(Config.Dir.Base, @"restart.vbs") } }; Log.Debug("Settings: OnRestart - executing script {0}", restartScript.StartInfo.FileName); restartScript.Start(); try { // Maybe the scripting host is not available therefore do not wait infinitely. if (!restartScript.HasExited) { restartScript.WaitForExit(); } } catch (Exception ex) { Log.Error("Settings: OnRestart - WaitForExit: {0}", ex.Message); } }
void airplayServer_VolumeChanged(object sender, ShairportSharp.Airplay.VolumeChangedEventArgs e) { invoke(delegate() { if (isVideoPlaying) { VolumeHandler volumeHandler = VolumeHandler.Instance; if (savedVolume == null) { savedVolume = volumeHandler.Volume; } if (e.Volume == 0) { volumeHandler.Volume = volumeHandler.Minimum; } else if (e.Volume == 1) { volumeHandler.Volume = volumeHandler.Maximum; } else { double factor = volumeHandler.Maximum / 0.9; volumeHandler.Volume = (int)(factor - factor / Math.Pow(10, e.Volume)); } } }, false); }
public static VolumeHandler getInstance() { if (instance == null) { instance = new VolumeHandler(); } return(instance); }
/// <summary> /// Constructor which initialises the internal osd handler /// </summary> /// <param name="player">Instance of external player</param> /// <param name="playerUse">Indicates, if this instance will be used by the player class</param> public InternalOSDHandler(MPlayerExtPlayer player, bool playerUse) { _player = player; _displayDuration = 2000; _osdVisible = false; _osdVisibleForPause = false; _mpVolumeHandler = VolumeHandler.Instance; if (playerUse) { _mpMessageHandler = OnMessage; GUIWindowManager.Receivers += _mpMessageHandler; } }
public static void RestartMP() { bool hideTaskBar = false; using (Settings xmlreader = new MPSettings()) { hideTaskBar = xmlreader.GetValueAsBool("general", "hidetaskbar", false); } if (hideTaskBar) { Win32API.EnableStartBar(true); Win32API.ShowStartBar(true); } Log.Info("argustv: OnRestart - prepare for restart!"); File.Delete(Config.GetFile(Config.Dir.Config, "mediaportal.running")); Log.Info("argustv: OnRestart - saving settings..."); Settings.SaveCache(); Log.Info("argustv: disposing databases."); FolderSettings.Dispose(); PictureDatabase.Dispose(); VideoDatabase.Dispose(); MusicDatabase.Dispose(); VolumeHandler.Dispose(); System.Diagnostics.Process restartScript = new System.Diagnostics.Process(); restartScript.EnableRaisingEvents = false; restartScript.StartInfo.WorkingDirectory = Config.GetFolder(Config.Dir.Base); restartScript.StartInfo.FileName = Config.GetFile(Config.Dir.Base, @"restart.vbs"); Log.Debug("argustv: OnRestart - executing script {0}", restartScript.StartInfo.FileName); restartScript.Start(); try { // Maybe the scripting host is not available therefore do not wait infinitely. if (!restartScript.HasExited) { restartScript.WaitForExit(); } } catch (Exception ex) { Log.Error("argustv: OnRestart - WaitForExit: {0}", ex.Message); } }
private void SetupProgramVars(object sender, EventArgs e) { VolumeTextLabel.Font = tbvolscroll.Properties.Settings.Default.FontStyle; int CurrentVolume = (int)Math.Round(VolumeHandler.GetMasterVolume()); VolumeTextLabel.Text = $"{CurrentVolume}%"; TrayNotifyIcon.Text = $"{Assembly.GetEntryAssembly().GetName().Name} - {CurrentVolume}%"; MaximumSize = new Size(100 + tbvolscroll.Properties.Settings.Default.BarWidth, tbvolscroll.Properties.Settings.Default.BarHeight); MinimumSize = new Size(tbvolscroll.Properties.Settings.Default.BarWidth, tbvolscroll.Properties.Settings.Default.BarHeight); Width = 100 + tbvolscroll.Properties.Settings.Default.BarWidth; Height = tbvolscroll.Properties.Settings.Default.BarHeight; Hide(); IntPtr hwnd = FindWindow("Shell_traywnd", ""); GetWindowRect(hwnd, out TaskbarRect); inputHandler = new InputHandler(this); }
void airtunesServer_VolumeChanged(object sender, ShairportSharp.Raop.VolumeChangedEventArgs e) { invoke(delegate() { if (isAudioPlaying) { VolumeHandler volumeHandler = VolumeHandler.Instance; if (savedVolume == null) { savedVolume = volumeHandler.Volume; } if (e.Volume < -30) { volumeHandler.IsMuted = true; } else { double percent = (e.Volume + 30) / 30; volumeHandler.Volume = (int)(volumeHandler.Maximum * percent); } } }, false); }
// Update is called once per frame void Update() { audioSrc.volume = VolumeHandler.getInstance().getVolume(); }
protected void SetState(State s) { state = s; volHandler = () => TemplateVolume(s); }
public void DoVolumeChanges(int delta) { try { Invoke((MethodInvoker)delegate { int CurrentVolume = (int)Math.Round(VolumeHandler.GetMasterVolume()); if (CursorInTaskbar() && !IsTaskbarHidden()) { inputHandler.TimeOutHelper = 10; if (delta < 0) { if (inputHandler.IsAltDown) { VolumeHandler.SetMasterVolume(CurrentVolume - 1); } else if (CurrentVolume <= tbvolscroll.Properties.Settings.Default.PreciseScrollThreshold) { VolumeHandler.SetMasterVolume(CurrentVolume - 1); } else { VolumeHandler.SetMasterVolume(CurrentVolume - tbvolscroll.Properties.Settings.Default.VolumeStep); } } else { if (inputHandler.IsAltDown) { VolumeHandler.SetMasterVolume(CurrentVolume + 1); } else if (CurrentVolume < tbvolscroll.Properties.Settings.Default.PreciseScrollThreshold) { VolumeHandler.SetMasterVolume(CurrentVolume + 1); } else { VolumeHandler.SetMasterVolume(CurrentVolume + tbvolscroll.Properties.Settings.Default.VolumeStep); } } CurrentVolume = (int)Math.Round(VolumeHandler.GetMasterVolume()); VolumeTextLabel.Text = $"{CurrentVolume}%"; TrayNotifyIcon.Text = $"{Assembly.GetEntryAssembly().GetName().Name} - {CurrentVolume}%"; Point CursorPosition = Cursor.Position; Width = CurrentVolume + tbvolscroll.Properties.Settings.Default.BarWidth; Left = CursorPosition.X - Width / 2; Top = CursorPosition.Y - Height - 5; VolumeTextLabel.Top = 1; VolumeTextLabel.Left = 1; VolumeTextLabel.Height = Height - 2; VolumeTextLabel.Width = Width - 2; Opacity = tbvolscroll.Properties.Settings.Default.BarOpacity; if (tbvolscroll.Properties.Settings.Default.UseBarGradient) { VolumeTextLabel.BackColor = CalculateColor(CurrentVolume); } else { VolumeTextLabel.BackColor = tbvolscroll.Properties.Settings.Default.BarColor; } if (!IsDisplayingVolume) { IsDisplayingVolume = true; Application.DoEvents(); AutoHideVolume(); } } else { Invoke((MethodInvoker)delegate { Hide(); }); IsDisplayingVolume = false; } }); } catch { } }
// Takes Volume value passed by slider public void SetVolume(float vol) { musicVolumeStart = vol; VolumeHandler.getInstance().setVolume(musicVolumeStart); }
public void UnsubEventVolume(VolumeHandler dl) { _audioPlayer.VolumeEvent -= dl; }
public void SubEventVolume(VolumeHandler dl) { _audioPlayer.VolumeEvent += dl; }