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(); }
public XbmcHandler(XbmcJsonRpcConnection xbmc, DisplayHandler display) { if (xbmc == null) { throw new ArgumentNullException("xbmc"); } if (display == null) { throw new ArgumentNullException("display"); } this.xbmc = xbmc; this.display = display; this.xbmc.Connected += this.xbmcConnected; this.xbmc.Aborted += this.xbmcAborted; this.xbmc.Player.PlaybackStarted += this.xbmcPlaybackStarted; this.xbmc.Player.PlaybackPaused += this.xbmcPlaybackPaused; //this.xbmc.Player.PlaybackResumed += this.xbmcPlaybackResumed; this.xbmc.Player.PlaybackStopped += this.xbmcPlaybackStopped; //this.xbmc.Player.PlaybackEnded += this.xbmcPlaybackEnded; this.xbmc.Player.PlaybackSeek += this.xbmcPlaybackSeek; this.xbmc.Player.PlaybackSeekChapter += this.xbmcPlaybackSeek; this.xbmc.Player.PlaybackSpeedChanged += this.xbmcPlaybackSpeedChanged; this.progressTimer = new System.Timers.Timer(); this.progressTimer.Interval = ProgressUpdateInterval; this.progressTimer.Elapsed += progressTimerUpdate; this.progressTimer.AutoReset = true; this.systemTimeTimer = new System.Timers.Timer(); this.systemTimeTimer.Interval = SystemTimeUpdateInterval; this.systemTimeTimer.Elapsed += systemTimeTimerUpdate; this.systemTimeTimer.AutoReset = true; this.WorkerReportsProgress = false; this.WorkerSupportsCancellation = true; this.controlModeState = new ControlState(); this.controlModeTimer = new System.Timers.Timer(); this.controlModeTimer.Interval = ControlModeUpdateInterval; this.controlModeTimer.Elapsed += controlModeTimerUpdate; this.controlModeTimer.AutoReset = true; this.semReady = new Semaphore(0, 1); this.semWork = new Semaphore(0, 1); }
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); } }