public VolumeHandler(int[] volumeTable) { bool isDigital; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } isDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); } _mixer = new Mixer.Mixer(); _mixer.Open(0, isDigital); _volumeTable = volumeTable; _mixer.ControlChanged += mixer_ControlChanged; }
public VolumeHandler(int[] volumeTable) { bool isDigital = true; //string mixerControlledComponent = "Wave"; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { _startupVolume = _mixer.Volume; } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } //mixerControlledComponent = reader.GetValueAsString("volume", "controlledMixer", "Wave"); isDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); } _mixer = new Mixer.Mixer(); _mixer.Open(0, isDigital); _volumeTable = volumeTable; }
public VolumeHandler(int[] volumeTable) { bool isDigital = true; //string mixerControlledComponent = "Wave"; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { _startupVolume = _mixer.Volume; } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } //mixerControlledComponent = reader.GetValueAsString("volume", "controlledMixer", "Wave"); isDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); } _mixer = new Mixer.Mixer(); _mixer.Open(0, isDigital); _volumeTable = volumeTable; _mixer.ControlChanged += new Mixer.MixerEventHandler(mixer_ControlChanged); }
public VolumeHandler(int[] volumeTable) { if (GUIGraphicsContext.DeviceAudioConnected > 0) { bool isDigital; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } isDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); } try { _mixer = new Mixer.Mixer(); _mixer.Open(0, isDigital); _volumeTable = volumeTable; _mixer.ControlChanged += mixer_ControlChanged; } catch (Exception ex) { Log.Error("VolumeHandler: Mixer exception when init {0}", ex); } } else { _volumeTable = volumeTable; } }
protected virtual void SetVolume(int volume) { if (OSInfo.OSInfo.Win10OrLater()) { if (_mixer10 != null) { if (_mixer10.IsMuted) { _mixer10.IsMuted = false; } _mixer10.Volume = volume; } } else { if (_mixer != null) { // Check if mixer is still attached to the audio device we started with if (_mixer._audioDefaultDevice != null && _mixer._audioDefaultDevice.DeviceId != _mixer._audioDefaultDevice.DeviceIdCurrent) { _mixer = new Mixer.Mixer(); _mixer.Open(0, IsDigital, true); _mixer.ControlChanged += mixer_ControlChanged; if (_mixer == null) { return; } } if (_mixer.IsMuted) { _mixer.IsMuted = false; } _mixer.Volume = volume; } } }
public VolumeHandler(int[] volumeTable) { if (OSInfo.OSInfo.Win10OrLater()) { if (_MMdeviceEnumerator == null) { _MMdeviceEnumerator = new MMDeviceEnumerator(); } var mMdeviceList = _MMdeviceEnumerator.EnumAudioEndpoints(DataFlow.Render, DeviceState.Active); if (mMdeviceList.Count > 0) { var mMdevice = _MMdeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); if (mMdevice != null) { using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } IsDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); hideWindowsOSD = reader.GetValueAsBool("volume", "hideWindowsOSD", false); } try { _volumeTable = volumeTable; _mixer10 = new Mixer.Mixer10(); _mixer10.Open(0, IsDigital, volumeTable); } catch (Exception ex) { Log.Error("VolumeHandler: Mixer exception during init {0}", ex); } if (OSInfo.OSInfo.Win8OrLater() && hideWindowsOSD) { try { bool tempShowVolumeOSD = _showVolumeOSD; _showVolumeOSD = true; VolumeOSD = new HideVolumeOSD.HideVolumeOSDLib(IsMuted); VolumeOSD.HideOSD(); _showVolumeOSD = tempShowVolumeOSD; } catch { } } } } else { _volumeTable = volumeTable; } } else { if (GUIGraphicsContext.DeviceAudioConnected > 0) { using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } IsDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); hideWindowsOSD = reader.GetValueAsBool("volume", "hideWindowsOSD", false); } try { _mixer = new Mixer.Mixer(); _mixer.Open(0, IsDigital); _volumeTable = volumeTable; _mixer.ControlChanged += mixer_ControlChanged; } catch (Exception ex) { Log.Error("VolumeHandler: Mixer exception when init {0}", ex); } if (OSInfo.OSInfo.Win8OrLater() && hideWindowsOSD) { try { bool tempShowVolumeOSD = _showVolumeOSD; _showVolumeOSD = true; VolumeOSD = new HideVolumeOSD.HideVolumeOSDLib(IsMuted); VolumeOSD.HideOSD(); _showVolumeOSD = tempShowVolumeOSD; } catch { } } } else { _volumeTable = volumeTable; } } }
public VolumeHandler(int[] volumeTable) { if (GUIGraphicsContext.DeviceAudioConnected > 0) { bool hideWindowsOSD; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } IsDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); hideWindowsOSD = reader.GetValueAsBool("volume", "hideWindowsOSD", false); } try { _mixer = new Mixer.Mixer(); _mixer.Open(0, IsDigital); _volumeTable = volumeTable; _mixer.ControlChanged += mixer_ControlChanged; } catch (Exception ex) { Log.Error("VolumeHandler: Mixer exception when init {0}", ex); } if (OSInfo.OSInfo.Win8OrLater() && hideWindowsOSD) { try { bool tempShowVolumeOSD = _showVolumeOSD; _showVolumeOSD = false; VolumeOSD = new HideVolumeOSD.HideVolumeOSDLib(IsMuted); VolumeOSD.HideOSD(); _showVolumeOSD = tempShowVolumeOSD; } catch { } } } else { _volumeTable = volumeTable; } }