/// <summary> /// Start point of the plugin. /// This method gets called by MediaPortal. /// </summary> public void Start() { // Log Handler Log.OnNewLog += new Log.NewLogHandler(OnNewLog); var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).LastWriteTime; Log.Info("Version {0}.{1}.{2}.{3}, build on {4} at {5}.", version.Major, version.Minor, version.Build, version.Revision, buildDate.ToShortDateString(), buildDate.ToLongTimeString()); Log.Debug("Loading settings."); Settings.LoadSettings(); Settings.SaveSettings(); Log.Debug("Initialising event handler."); // PowerModeChanged Handler SystemEvents.PowerModeChanged += PowerModeChanged; // Screensaver Handler if (Settings.monitorScreensaverState) { Thread screensaverMonitorThread = new Thread(monitorScreensaverState); screensaverMonitorThread.IsBackground = true; screensaverMonitorThread.Start(); } // g_Player Handler g_Player.PlayBackStarted += new g_Player.StartedHandler(g_Player_PlayBackStarted); g_Player.PlayBackStopped += new g_Player.StoppedHandler(g_Player_PlayBackStopped); g_Player.PlayBackEnded += new g_Player.EndedHandler(g_Player_PlayBackEnded); // FrameGrabber Handler MediaPortal.FrameGrabber.GetInstance().OnNewFrame += new MediaPortal.FrameGrabber.NewFrameHandler(AtmolightPlugin_OnNewFrame); // Button Handler GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); // Connection Lost Handler Core.OnNewConnectionLost += new Core.NewConnectionLostHandler(OnNewConnectionLost); // VU Meter Handler Core.OnNewVUMeter += new Core.NewVUMeterHander(OnNewVUMeter); staticColorTemp[0] = Settings.staticColorRed; staticColorTemp[1] = Settings.staticColorGreen; staticColorTemp[2] = Settings.staticColorBlue; Log.Debug("Generating new AtmoLight.Core instance."); coreObject = Core.GetInstance(); // General settings coreObject.SetDelay(Settings.delayReferenceTime); if (Settings.delay) { coreObject.EnableDelay(); } coreObject.SetGIFPath(Settings.gifFile); coreObject.SetReInitOnError(Settings.restartOnError); coreObject.SetStaticColor(Settings.staticColorRed, Settings.staticColorGreen, Settings.staticColorBlue); coreObject.SetCaptureDimensions(Settings.captureWidth, Settings.captureHeight); coreObject.blackbarDetection = Settings.blackbarDetection; coreObject.blackbarDetectionTime = Settings.blackbarDetectionTime; coreObject.blackbarDetectionThreshold = Settings.blackbarDetectionThreshold; coreObject.powerModeChangedDelay = Settings.powerModeChangedDelay; coreObject.vuMeterMindB = Settings.vuMeterMindB; coreObject.vuMeterMinHue = Settings.vuMeterMinHue; coreObject.vuMeterMaxHue = Settings.vuMeterMaxHue; coreObject.blackbarDetectionHorizontal = Settings.blackbarDetectionHorizontal; coreObject.blackbarDetectionVertical = Settings.blackbarDetectionVertical; coreObject.blackbarDetectionLinkAreas = Settings.blackbarDetectionLinkAreas; // AmbiBox coreObject.ambiBoxIP = Settings.ambiBoxIP; coreObject.ambiBoxPort = Settings.ambiBoxPort; coreObject.ambiBoxMaxReconnectAttempts = Settings.ambiBoxMaxReconnectAttempts; coreObject.ambiBoxReconnectDelay = Settings.ambiBoxReconnectDelay; coreObject.ambiBoxMediaPortalProfile = Settings.ambiBoxMediaPortalProfile; coreObject.ambiBoxExternalProfile = Settings.ambiBoxExternalProfile; coreObject.ambiBoxPath = Settings.ambiBoxPath; coreObject.ambiBoxAutoStart = Settings.ambiBoxAutoStart; coreObject.ambiBoxAutoStop = Settings.ambiBoxAutoStop; if (Settings.ambiBoxTarget) { coreObject.AddTarget(Target.AmbiBox); } // AtmoOrb coreObject.atmoOrbBlackThreshold = Settings.atmoOrbBlackThreshold; coreObject.atmoOrbBroadcastPort = Settings.atmoOrbBroadcastPort; coreObject.atmoOrbGamma = Settings.atmoOrbGamma; coreObject.atmoOrbLamps = Settings.atmoOrbLamps; coreObject.atmoOrbMinDiversion = Settings.atmoOrbMinDiversion; coreObject.atmoOrbSaturation = Settings.atmoOrbSaturation; coreObject.atmoOrbThreshold = Settings.atmoOrbThreshold; coreObject.atmoOrbUseOverallLightness = Settings.atmoOrbUseOverallLightness; if (Settings.atmoOrbTarget) { coreObject.AddTarget(Target.AtmoOrb); } // AtmoWin coreObject.atmoWinPath = Settings.atmowinExe; coreObject.atmoWinAutoStart = Settings.startAtmoWin; coreObject.atmoWinAutoStop = Settings.exitAtmoWin; if (Settings.atmoWinTarget) { coreObject.AddTarget(Target.AtmoWin); } // Boblight coreObject.boblightIP = Settings.boblightIP; coreObject.boblightPort = Settings.boblightPort; coreObject.boblightMaxFPS = Settings.boblightMaxFPS; coreObject.boblightMaxReconnectAttempts = Settings.boblightMaxReconnectAttempts; coreObject.boblightReconnectDelay = Settings.boblightReconnectDelay; coreObject.boblightSpeed = Settings.boblightSpeed; coreObject.boblightAutospeed = Settings.boblightAutospeed; coreObject.boblightInterpolation = Settings.boblightInterpolation; coreObject.boblightSaturation = Settings.boblightSaturation; coreObject.boblightValue = Settings.boblightValue; coreObject.boblightThreshold = Settings.boblightThreshold; coreObject.boblightGamma = Settings.boblightGamma; if (Settings.boblightTarget) { coreObject.AddTarget(Target.Boblight); } // Hyperion coreObject.hyperionIP = Settings.hyperionIP; coreObject.hyperionPort = Settings.hyperionPort; coreObject.hyperionPriority = Settings.hyperionPriority; coreObject.hyperionReconnectDelay = Settings.hyperionReconnectDelay; coreObject.hyperionReconnectAttempts = Settings.hyperionReconnectAttempts; coreObject.hyperionPriorityStaticColor = Settings.hyperionPriorityStaticColor; coreObject.hyperionLiveReconnect = Settings.hyperionLiveReconnect; if (Settings.hyperionTarget) { coreObject.AddTarget(Target.Hyperion); } // Hue coreObject.huePath = Settings.hueExe; coreObject.hueStart = Settings.hueStart; coreObject.hueIsRemoteMachine = Settings.hueIsRemoteMachine; coreObject.hueIP = Settings.hueIP; coreObject.huePort = Settings.huePort; coreObject.hueReconnectDelay = Settings.hueReconnectDelay; coreObject.hueReconnectAttempts = Settings.hueReconnectAttempts; coreObject.hueBridgeEnableOnResume = Settings.hueBridgeEnableOnResume; coreObject.hueBridgeDisableOnSuspend = Settings.hueBridgeDisableOnSuspend; coreObject.hueMinDiversion = Settings.hueMinDiversion; coreObject.hueThreshold = Settings.hueThreshold; coreObject.hueBlackThreshold = Settings.hueBlackThreshold; coreObject.hueSaturation = Settings.hueSaturation; coreObject.hueUseOverallLightness = Settings.hueUseOverallLightness; if (Settings.hueTarget) { coreObject.AddTarget(Target.Hue); } // Get the effects that are supported by at least one target supportedEffects = coreObject.GetSupportedEffects(); menuEffect = Settings.effectMenu; if (CheckForStartRequirements()) { coreObject.ChangeEffect(menuEffect, true); CalculateDelay(); } else { coreObject.ChangeEffect(ContentEffect.LEDsDisabled, true); } coreObject.Initialise(); }