VideoInputProvider.cs 2.3 KB

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