using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using Iisu; using bbiwarg.Utility; namespace bbiwarg.Input.InputProviding { class VideoInputProvider : InputProvider { public override int CurrentFrameID { get { return currentMovieFrame.Value; } } public String MoviePath { get; private set; } public bool IsPaused { get; private set; } private IParameterHandle currentMovieFrame; private IParameterHandle frameCount; private IParameterHandle 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("SOURCE.MOVIE.PlayMode").Value = 1; // 0=once, 1=loop, 2=pingPong currentMovieFrame = device.RegisterParameterHandle("SOURCE.MOVIE.CurrentFrame"); frameCount = device.RegisterParameterHandle("SOURCE.MOVIE.FrameCount"); playStep = device.RegisterParameterHandle("SOURCE.MOVIE.PlayStep"); } public void pause() { IsPaused = true; } public void play() { IsPaused = false; } public void goToNextFrame() { nextFrame(); } public void goToPreviousFrame() { playStep.Value = -1; nextFrame(); playStep.Value = 1; } protected override void run() { while (IsActive) { if (!IsPaused) nextFrame(); else Thread.Sleep(30); } } } }