Beispiel #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     foreach (var dev in DirectSoundOut.Devices)
     {
         deviceComboBox.Items.Add(dev.Description);
         devices[dev.Description] = dev.ModuleName;
         if (dev.Description.Contains("扬声器") || dev.Description.Contains("Speaker"))
         {
             deviceComboBox.SelectedIndex = deviceComboBox.Items.IndexOf(dev.Description);
             notificationClient.setMonitorDeviceId(dev.ModuleName);
         }
     }
     this.Visible         = false;
     this.ShowInTaskbar   = false;
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.WindowState     = System.Windows.Forms.FormWindowState.Minimized;
     this.Hide();
 }
Beispiel #2
0
        static void Main()
        {
            foreach (var dev in DirectSoundOut.Devices)
            {
                Console.WriteLine($"{dev.Guid} {dev.ModuleName} {dev.Description}");
            }

            notificationClient = new NotificationClientImplementation();
            notificationClient.setMonitorDeviceId("{0.0.0.00000000}.{299801a3-11d5-4ae6-a926-0362223cebba}");
            notifyClient = (NAudio.CoreAudioApi.Interfaces.IMMNotificationClient)notificationClient;
            deviceEnum.RegisterEndpointNotificationCallback(notifyClient);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new HeadphoneDaemon(notificationClient));
        }