Пример #1
0
 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);
         sessionControlStackPanel.Children.Add(sessionUI);
     });
 }
Пример #2
0
        private void EnumerateSessions()
        {
            selectedDevice = ((RenderDevice)deviceBox.SelectedItem).Device;
            audioSessionManager2.OnSessionCreated -= OnSessionCreated;
            audioSessionManager2 = selectedDevice.AudioSessionManager2;
            audioSessionManager2.OnSessionCreated += OnSessionCreated;
            audioSessionManager2.RefreshSessions();
            SessionCollection sessions = audioSessionManager2.Sessions;

            sessionControlStackPanel.Children.Clear();

            foreach (AudioSessionControl2 session in sessions)
            {
                if (session.State != AudioSessionState.AudioSessionStateExpired)
                {
                    SessionUI sessionUI = new SessionUI();
                    sessionUI.SetSession(session);
                    sessionControlStackPanel.Children.Add(sessionUI);
                }
            }
        }