Ejemplo n.º 1
0
        public static IServiceCollection AddLibCec(this IServiceCollection services, Action <LibCecConfig> configure)
        {
            var options = new LibCecConfig();

            configure?.Invoke(options);

            if (options.Enabled)
            {
                services.TryAddSingleton <ICecManager>(s =>
                {
                    var cecManager = new CecManager(options.HdmiPort, options.Port);
                    cecManager.Start();
                    return(cecManager);
                });
                services.TryAddSingleton <ICecManagerService, CecManagerService>();

                services.TryAddScoped(typeof(ICecSwitchRepository <,>), typeof(CecSwitchRepository <,>));

                services.AdditionalSwitchConfiguration(o =>
                {
                    o.AddSwitch(typeof(ICecSwitchRepository <,>));
                });
            }

            return(services);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //var lirc = new WinLirc();
            //lirc.SendMessage("LG_TV Power");

            using (var cecManager = new CecManager(-1, "com3"))
            {
                cecManager.Start();

                foreach (var device in cecManager.Scan())
                {
                    Console.WriteLine($"Device {device}");
                    //Console.WriteLine($"Name: {cecManager.GetName(device)}");
                    Console.WriteLine($"Vendor: {cecManager.GetVendor(device)}");
                    Console.WriteLine($"Power: {cecManager.GetPower(device)}");
                }
                //cecManager.SetStandby(CecLogicalAddress.TV);
                //Console.ReadKey();
                //cecManager.SetOn(CecLogicalAddress.TV);
            }

            Console.ReadKey();
        }