VideoInputProvider.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using Iisu;
  7. using bbiwarg.Utility;
  8. namespace bbiwarg.Input.InputProviding
  9. {
  10. class VideoInputProvider : InputProvider
  11. {
  12. public override int CurrentFrameID { get { return currentMovieFrame.Value; } }
  13. public String MoviePath { get; private set; }
  14. public bool IsPaused { get; private set; }
  15. private IParameterHandle<int> currentMovieFrame;
  16. private IParameterHandle<int> frameCount;
  17. private IParameterHandle<int> playStep;
  18. public VideoInputProvider(String moviePath)
  19. {
  20. MoviePath = moviePath;
  21. }
  22. protected override IDeviceConfiguration createDeviceConfiguration()
  23. {
  24. IDeviceConfiguration conf = base.createDeviceConfiguration();
  25. conf.MoviePath = MoviePath;
  26. return conf;
  27. }
  28. protected override void registerHandles()
  29. {
  30. base.registerHandles();
  31. device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayMode").Value = 1; // 0=once, 1=loop, 2=pingPong
  32. currentMovieFrame = device.RegisterParameterHandle<int>("SOURCE.MOVIE.CurrentFrame");
  33. frameCount = device.RegisterParameterHandle<int>("SOURCE.MOVIE.FrameCount");
  34. playStep = device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayStep");
  35. }
  36. public void pause()
  37. {
  38. IsPaused = true;
  39. }
  40. public void play()
  41. {
  42. IsPaused = false;
  43. }
  44. public void goToNextFrame()
  45. {
  46. nextFrame();
  47. }
  48. public void goToPreviousFrame()
  49. {
  50. playStep.Value = -1;
  51. nextFrame();
  52. playStep.Value = 1;
  53. }
  54. protected override void run() {
  55. while (IsActive) {
  56. if (!IsPaused)
  57. nextFrame();
  58. else
  59. Thread.Sleep(30);
  60. }
  61. }
  62. }
  63. }