Пример #1
0
        private static void DebugInfo(CecSharpClient p)
        {
            if (p.Lib.IsActiveDevice(CecLogicalAddress.Tv))
            {
                int tvVendorId = (int)p.Lib.GetDeviceVendorId(CecLogicalAddress.Tv);
                Console.WriteLine("tvVendorId " + tvVendorId);
            }

            bool hasAVRDevice = p.Lib.IsActiveDevice(CecLogicalAddress.AudioSystem);

            if (hasAVRDevice)
            {
                int avrVendorId = (int)p.Lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem);
                Console.WriteLine("avrVendorId " + avrVendorId);
            }

            Console.WriteLine("Active Devices:");
            var activeDevices = p.Lib.GetActiveDevices();

            foreach (var activeDevice in activeDevices.Addresses)
            {
                if (activeDevice != CecLogicalAddress.Unknown)
                {
                    Console.WriteLine(string.Format("{0,1:X} : {1}", (int)activeDevice, p.Lib.ToString(activeDevice)));
                }
            }
            Console.WriteLine(string.Format("{0,1:X} : {1}", (int)CecLogicalAddress.Broadcast, p.Lib.ToString(CecLogicalAddress.Broadcast)));
        }
Пример #2
0
        static void Main(string[] args)
        {
            SetupNotifyIcon();

            CecSharpClient p = new CecSharpClient();

            if (p.Connect(10000))
            {
                DebugInfo(p);

                // Start with disabled console
                ToggleConsoleVisibility();

                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    SuspendWhenKodiActive(p);
                }).Start();

                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = false;
                    p.MainLoop();
                }).Start();

                Application.Run();
            }
            else
            {
                Console.WriteLine("Could not open a connection to the CEC adapter");
                Console.ReadLine();
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            CecSharpClient p = new CecSharpClient();

            if (p.Connect(10000))
            {
                p.MainLoop();
            }
            else
            {
                Console.WriteLine("Could not open a connection to the CEC adapter");
            }
        }
Пример #4
0
        private static void SuspendWhenKodiActive(CecSharpClient client)
        {
            while (true)
            {
                while (!IsRunning("kodi"))
                {
                    Thread.Sleep(200);
                }

                Console.WriteLine("Kodi is active, suspend operations!");
                client.Close();

                while (IsRunning("kodi"))
                {
                    Thread.Sleep(200);
                }

                Console.WriteLine("Kodi is gone, resume operations!");
                client.Connect(10000);
            }
        }
Пример #5
0
 static void Main(string[] args)
 {
   CecSharpClient p = new CecSharpClient();
   if (p.Connect(10000))
   {
     p.MainLoop();
   }
   else
   {
     Console.WriteLine("Could not open a connection to the CEC adapter");
   }
 }