public void UpdateSession(int sessionIndex, float newVolume) { if (sessionIndex >= sessions.Count) { return; } SessionUI sessionUI = sessions[sessionIndex]; if (sessionUI == null) { return; } UpdateSession(sessionIndex, newVolume, sessionUI.session.SimpleAudioVolume.Mute); }
public void UpdateSession(int sessionIndex, bool newMute) { if (sessionIndex >= sessions.Count) { return; } SessionUI sessionUI = sessions[sessionIndex]; if (sessionUI == null) { return; } UpdateSession(sessionIndex, sessionUI.session.SimpleAudioVolume.MasterVolume, newMute); }
private void OnSessionCreated(object sender, CoreAudio.Interfaces.IAudioSessionControl2 newSession) { Dispatcher.Invoke(() => { SessionUI sessionUI = new SessionUI(); ConstructorInfo contructor = typeof(AudioSessionControl2).GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)[0]; AudioSessionControl2 session = contructor.Invoke(new object[] { newSession }) as AudioSessionControl2; sessionUI.SetSession(session); sessionStackPanel.Children.Add(sessionUI); this.sessions.Add(sessionUI); MainWindow.instance.SendAudioSession(sessions.IndexOf(sessionUI), session.SimpleAudioVolume.MasterVolume, session.SimpleAudioVolume.Mute, true); //Session_OnSimpleVolumeChanged(session, session.SimpleAudioVolume.MasterVolume, session.SimpleAudioVolume.Mute); SessionVolumeChanged(session, session.SimpleAudioVolume.MasterVolume, session.SimpleAudioVolume.Mute); //sessionUI.session.OnSimpleVolumeChanged += Session_OnSimpleVolumeChanged; }); }
public void UpdateSession(int sessionIndex, float newVolume, bool newMute) { if (sessionIndex >= sessions.Count) { return; } SessionUI sessionUI = sessions[sessionIndex]; if (sessionUI == null) { return; } //sessionUI.session.OnSimpleVolumeChanged -= Session_OnSimpleVolumeChanged; sessionUI.UpdateSession(this, newVolume, newMute); //sessionUI.session.OnSimpleVolumeChanged += Session_OnSimpleVolumeChanged; }
private void EnumerateSessions() { selectedDevice = ((RenderDevice)deviceComboBox.SelectedItem).Device; audioSessionManager2.OnSessionCreated -= OnSessionCreated; audioSessionManager2 = selectedDevice.AudioSessionManager2; audioSessionManager2.OnSessionCreated += OnSessionCreated; audioSessionManager2.RefreshSessions(); SessionCollection sessions = audioSessionManager2.Sessions; sessionStackPanel.Children.Clear(); foreach (AudioSessionControl2 session in sessions) { if (session.State != AudioSessionState.AudioSessionStateExpired) { SessionUI sessionUI = new SessionUI(); sessionUI.SetSession(session); //sessionUI.session.OnSimpleVolumeChanged += Session_OnSimpleVolumeChanged; sessionStackPanel.Children.Add(sessionUI); this.sessions.Add(sessionUI); } } }