private void xbmcSetup() { Logging.Log("Setting up XBMC connection to " + Settings.Default.XbmcIp + ":" + Settings.Default.XbmcPort); this.xbmc = new XbmcJsonRpcConnection(Settings.Default.XbmcIp, Settings.Default.XbmcPort, Settings.Default.XbmcUsername, Settings.Default.XbmcPassword); this.xbmc.System.Hibernating += xbmcShutdown; this.xbmc.System.ShuttingDown += xbmcShutdown; this.xbmc.System.Rebooting += xbmcShutdown; this.xbmc.System.Sleeping += xbmcShutdown; this.xbmc.System.Suspending += xbmcShutdown; this.xbmc.Aborted += xbmcShutdown; this.xbmc.LogError += wrapperApiXbmcLogError; if (Settings.Default.GeneralDebugEnable) { this.xbmc.Log += wrapperApiXbmcLog; } this.xbmcHandler = new XbmcHandler(this.xbmc, this.displayHandler); this.xbmcHandler.RunWorkerAsync(); if (Settings.Default.GeneralStartupConnect) { Logging.Log("Auto-connecting to XBMC at startup"); this.xbmcConnect(true); } }
static void Main(string[] args) { using (XbmcJsonRpcConnection xbmc = new XbmcJsonRpcConnection("127.0.0.1", 8080)) { Console.Out.Write("Connecting to XBMC..."); if (!xbmc.Open()) { Console.Out.WriteLine("failed"); } else { xbmc.Aborted += xbmc_Aborted; xbmc.Player.PlaybackStarted += xbmc_PlaybackStarted; xbmc.Player.PlaybackPaused += xbmc_PlaybackPaused; xbmc.Player.PlaybackResumed += xbmc_PlaybackResumed; xbmc.Player.PlaybackStopped += xbmc_PlaybackStopped; xbmc.Player.PlaybackEnded += xbmc_PlaybackEnded; xbmc.Player.PlaybackSeek += xbmc_PlaybackSeek; xbmc.Player.PlaybackSpeedChanged += xbmc_PlaybackSpeedChanged; Console.Out.WriteLine("succeeded (Version {0})", xbmc.JsonRpc.Version()); Console.Out.WriteLine("Press <Enter> to disconnect..."); xbmc.Playlist.Video.GetCurrentItem(); /*while (true) * { * IDictionary<string, string> info = xbmc.System.GetInfoLabels("System.CurrentWindow", "System.CurrentControl"); * if (info.Count == 2) * { * Console.Out.WriteLine("Window = {0}", info["System.CurrentWindow"]); * Console.Out.WriteLine("Control = {0}", info["System.CurrentControl"]); * } * * Thread.Sleep(1000); * }*/ while (!aborted) { int ch = Console.In.Peek(); if (ch == '\n' || ch == '\r') { Console.In.ReadLine(); break; } } } } Console.Out.Write("Press <Enter> to close..."); Console.In.ReadLine(); }