 AtmoLight.MediaPortal1/Plugin.cs | 81 ++++++++++++++++++++++++++++------------
 1 file changed, 58 insertions(+), 23 deletions(-)

diff --git a/AtmoLight.MediaPortal1/Plugin.cs b/AtmoLight.MediaPortal1/Plugin.cs
index ede4374..bec5332 100644
--- a/AtmoLight.MediaPortal1/Plugin.cs
+++ b/AtmoLight.MediaPortal1/Plugin.cs
@@ -4,7 +4,6 @@ using System.Collections.Generic;
 using System.Text;
 using System.Drawing;
 using System.Drawing.Imaging;
-using MediaPortal;
 using MediaPortal.GUI.Library;
 using MediaPortal.Profile;
 using MediaPortal.Player;
@@ -57,6 +56,14 @@ namespace AtmoLight
     // Core object
     private Core coreObject;
 
+    //FrameSource enum for NewFrameHandler 
+    private enum FrameSource
+    {
+        undefined = -1,
+        GUI = 0,
+        Video
+    }
+
     #endregion
 
     #region Plugin Ctor/Start/Stop
@@ -514,6 +521,53 @@ namespace AtmoLight
         Log.Error("Exception= {0}", ex.Message);
       }
     }
+    /// <summary>
+    /// Calculates the pixel data that gets send to AtmoWin.
+    /// And starts the SetPixelDataThread() threads to send the data.
+    /// </summary>
+    /// <param name="width">Frame width.</param>
+    /// <param name="height">Frame height.</param>
+    /// <param name="arWidth">Aspect ratio width.</param>
+    /// <param name="arHeight">Aspect ratio height.</param>
+    /// <param name="pSurface">Surface.</param>
+    /// <param name="iFrameSource">Source of frame, see enums FrameGrabber.FrameSource</param>/// 
+    private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface, int iFrameSource = (int)FrameSource.undefined)
+    {
+        if (coreObject.GetCurrentEffect() != ContentEffect.MediaPortalLiveMode || !coreObject.IsConnected() || !coreObject.IsAtmoLightOn() || width == 0 || height == 0)
+        {
+            return;
+        }
+
+        //Cast iFrameSource to an FrameSourceEnum
+        FrameSource FrmSource = FrameSource.Video;
+        try
+        {
+            FrmSource = (FrameSource)iFrameSource;
+        }catch{}
+
+        //Drop any frames?
+        if (Settings.trueGrabbing)
+        {
+            //GUI grabbing while video is minimized activated
+            if (g_Player.Playing && (!GUIGraphicsContext.IsFullScreenVideo) && (FrmSource == FrameSource.Video))
+            {
+                //Drop Video frames when user has set TrueGrabbing & video is playing minimized -> just GUI frames will pass
+                return;
+            }
+        }
+        else
+        {
+            //GUI grabbing while video is minimized deactivated
+            if ((g_Player.Playing) && (FrmSource == FrameSource.GUI))
+            {
+                //Drop GUI frames when user has NOT set TrueGrabbing & video is playing -> just video frames will pass
+
+                return;
+            }
+        }
+        Log.Debug("AtmolightPlugin_OnNewFrame FrmSource: " + FrmSource.ToString());
+        AtmolightPlugin_OnNewFrame(width, height, arWidth, arHeight, pSurface);
+    }
 
     /// <summary>
     /// Calculates the pixel data that gets send to AtmoWin.
@@ -524,34 +578,13 @@ namespace AtmoLight
     /// <param name="arWidth">Aspect ratio width.</param>
     /// <param name="arHeight">Aspect ratio height.</param>
     /// <param name="pSurface">Surface.</param>
-    /// <param name="FrameSource">Source of frame, see enums FrameGrabber.FrameSource</param>/// 
-    private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface, FrameGrabber.FrameSource FrameSource)
+    private void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface)
     {
       if (coreObject.GetCurrentEffect() != ContentEffect.MediaPortalLiveMode || !coreObject.IsConnected() ||
           !coreObject.IsAtmoLightOn() || width == 0 || height == 0)
       {
         return;
       }
-	  
-      //Drop any frames?
-      if (Settings.trueGrabbing)
-      {
-          //GUI grabbing while video is minimized activated 
-          if (g_Player.Playing && (!GUIGraphicsContext.IsFullScreenVideo) && (FrameSource == FrameGrabber.FrameSource.Video))
-          {
-            //Drop Video frames when user has set TrueGrabbing & video is playing minimized -> just GUI frames will pass
-            return;
-          }
-      }
-      else
-      {
-          //GUI grabbing while video is minimized deactivated 
-          if((g_Player.Playing) && (FrameSource == FrameGrabber.FrameSource.GUI))
-          {
-              //Drop GUI frames when user has NOT set TrueGrabbing & video is playing -> just video frames will pass
-            return;
-          }
-      }	  
 
       // Low CPU setting.
       // Skip frame if LowCPUTime has not yet passed since last frame.
@@ -567,6 +600,8 @@ namespace AtmoLight
         }
       }
 
+      Log.Debug("AtmolightPlugin_OnNewFrame proccess!");
+
       if (rgbSurface == null)
       {
         rgbSurface = GUIGraphicsContext.DX9Device.CreateRenderTarget(coreObject.GetCaptureWidth(),
