123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Iisu;
- using bbiwarg.Utility;
- namespace bbiwarg.InputProviders
- {
- class VideoInputProvider : InputProvider
- {
- public override int CurrentFrameID { get { return currentMovieFrame.Value; } }
- public String MoviePath { get; private set; }
- public bool IsPaused { get { return (playStep.Value == 0); } }
- private IParameterHandle<int> currentMovieFrame;
- private IParameterHandle<int> frameCount;
- private IParameterHandle<int> playStep;
- public VideoInputProvider(String moviePath)
- {
- MoviePath = moviePath;
- }
- protected override IDeviceConfiguration createDeviceConfiguration()
- {
- IDeviceConfiguration conf = base.createDeviceConfiguration();
- conf.MoviePath = MoviePath;
- return conf;
- }
- protected override void registerHandles()
- {
- base.registerHandles();
- 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");
- }
- public void pause()
- {
- playStep.Value = 0;
- Logger.log("Video pause", LogSubject.VideoControls);
- }
- public void play()
- {
- playStep.Value = 1;
- Logger.log("Video play", LogSubject.VideoControls);
- }
- public void nextFrame()
- {
- playStep.Value = 1;
- int nextFrame = Math.Min((currentMovieFrame.Value + 1), frameCount.Value - 1);
- while (currentMovieFrame.Value != nextFrame)
- {
- device.UpdateFrame(true);
- device.ReleaseFrame();
- }
- playStep.Value = 0;
- Logger.log("Video nextFrame", LogSubject.VideoControls);
- }
- public void previousFrame()
- {
- playStep.Value = -1;
- int previousFrame = Math.Max((currentMovieFrame.Value - 1), 0);
- while (currentMovieFrame.Value != previousFrame)
- {
- device.UpdateFrame(true);
- device.ReleaseFrame();
- }
- playStep.Value = 0;
- Logger.log("Video previousFrame", LogSubject.VideoControls);
- }
- }
- }
|