Parcourir la source

fixed videoInputProvider next/previous frame at start/end of movie

Alexander Hendrich il y a 10 ans
Parent
commit
5fe760f528
2 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 1 1
      bbiwarg/Constants.cs
  2. 4 2
      bbiwarg/InputProviders/VideoInputProvider.cs

+ 1 - 1
bbiwarg/Constants.cs

@@ -18,7 +18,7 @@ namespace bbiwarg
     class Constants
     {
         // input
-        public static readonly InputType InputSource = InputType.Camera;
+        public static readonly InputType InputSource = InputType.Movie;
         public static readonly String InputMoviePath = "..\\..\\videos\\touch\\4.skv";
 
         // Logger

+ 4 - 2
bbiwarg/InputProviders/VideoInputProvider.cs

@@ -15,6 +15,7 @@ namespace bbiwarg.InputProviders
         public bool IsPaused { get { return (playStep.Value == 0); } }
 
         private IParameterHandle<int> currentMovieFrame;
+        private IParameterHandle<int> frameCount;
         private IParameterHandle<int> playStep;
 
         public VideoInputProvider(String moviePath)
@@ -35,6 +36,7 @@ namespace bbiwarg.InputProviders
 
             device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayMode").Value = 1; // 0=once, 1=loop, 2=pingPong
             currentMovieFrame = device.RegisterParameterHandle<int>("SOURCE.MOVIE.CurrentFrame");
+            frameCount = device.RegisterParameterHandle<int>("SOURCE.MOVIE.FrameCount");
             playStep = device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayStep");
         }
 
@@ -53,7 +55,7 @@ namespace bbiwarg.InputProviders
         public void nextFrame()
         {
             playStep.Value = 1;
-            int nextFrame = currentMovieFrame.Value + 1;
+            int nextFrame = Math.Min((currentMovieFrame.Value + 1), frameCount.Value - 1);
             while (currentMovieFrame.Value != nextFrame)
             {
                 device.UpdateFrame(true);
@@ -66,7 +68,7 @@ namespace bbiwarg.InputProviders
         public void previousFrame()
         {
             playStep.Value = -1;
-            int previousFrame = currentMovieFrame.Value - 1;
+            int previousFrame = Math.Max((currentMovieFrame.Value - 1), 0);
             while (currentMovieFrame.Value != previousFrame)
             {
                 device.UpdateFrame(true);