Esempio n. 1
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            //Console.Beep();

            ////Console.WriteLine("Hello World!");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Console.WriteLine($"{sw.Elapsed}");
            var ac = new CoreAudioController();
            ////var devices = ac.GetDevices().ToList();

            ////var activeDevices = devices.Where(c => c.State == AudioSwitcher.AudioApi.DeviceState.Active).ToArray();


            ////ac.GetDevice()

            ////var item = activeDevices.First(c => c.InterfaceName.Contains("AC511"));
            ////item.IsDefaultDevice
            ///
            var ddId = ac.GetDefaultDeviceId(DeviceType.Playback, Role.Communications);

            //var id = ac.DefaultPlaybackDevice.Id;


            //var nextDevceGuid = id == GUID_AT2020P ?
            //        GUID_SPEKER : GUID_AT2020P;

            var nextDevceRealId = ddId == REALID_AT2020P ?
                                  REALID_SPEKER : REALID_AT2020P;



            Console.WriteLine($"{sw.Elapsed}");
            //var device = ac.GetDevice(nextDevceGuid);
            //Console.WriteLine($"{sw.Elapsed}");
            //device.SetAsDefault();

            PolicyConfig.SetDefaultEndpoint(nextDevceRealId, ERole.Console | ERole.Communications);
            PolicyConfig.SetDefaultEndpoint(nextDevceRealId, ERole.Console | ERole.Multimedia);

            Console.WriteLine($"{sw.Elapsed}");
            //new CoreAudioDevice(item, ac);
            //await ac.DefaultPlaybackDevice.SetAs(false);

//            item.SetAsDefault();
        }