WVPNative.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using UnityEngine;
  4. namespace Nfynt.WVP
  5. {
  6. internal class WVPNative
  7. {
  8. const string PLUGIN ="__Internal";
  9. enum PlayerStates {
  10. NA= 0,
  11. Opening= 1,
  12. Buffering,
  13. ImageReady,
  14. Prepared,
  15. Playing,
  16. Paused,
  17. Stopped,
  18. EndReached,
  19. EncounteredError,
  20. TimeChanged,
  21. PositionChanged,
  22. };
  23. #if UNITY_WEBGL
  24. [DllImport(PLUGIN)]
  25. public static extern int WVPInitialize(bool autoplay, bool loop, bool muted);
  26. [DllImport(PLUGIN)]
  27. public static extern void WVPUpdateTexture(int indx, IntPtr texId);
  28. [DllImport(PLUGIN)]
  29. public static extern void WVPSetDataSource(int indx, string path);
  30. [DllImport(PLUGIN)]
  31. public static extern bool WVPSourceIsReady(int indx);
  32. [DllImport(PLUGIN)]
  33. public static extern bool WVPSourcePlay(int indx);
  34. [DllImport(PLUGIN)]
  35. public static extern void WVPSourceStop(int indx);
  36. [DllImport(PLUGIN)]
  37. public static extern void WVPSourcePause(int indx);
  38. [DllImport(PLUGIN)]
  39. public static extern void WVPSourceRelease(int indx);
  40. [DllImport(PLUGIN)]
  41. public static extern bool WVPSourceIsPlaying(int indx);
  42. [DllImport(PLUGIN)]
  43. public static extern float WVPSourceDuration(int indx);
  44. [DllImport(PLUGIN)]
  45. public static extern bool WVPSourceIsMute(int indx);
  46. [DllImport(PLUGIN)]
  47. public static extern void WVPSourceSetMute(int indx, bool mute);
  48. [DllImport(PLUGIN)]
  49. public static extern void WVPSourceSetLoop(int indx, bool loop);
  50. [DllImport(PLUGIN)]
  51. public static extern int WVPSourceWidth(int indx);
  52. [DllImport(PLUGIN)]
  53. public static extern int WVPSourceHeight(int indx);
  54. [DllImport(PLUGIN)]
  55. public static extern double WVPSourceFrameTime(int indx);
  56. [DllImport(PLUGIN)]
  57. public static extern void WVPSourceSetFrameTime(int indx, double timeInSec);
  58. #else
  59. public static int WVPInitialize(bool autoplay, bool loop, bool muted){return -1;}
  60. public static void WVPUpdateTexture(int indx, IntPtr texId){}
  61. public static void WVPSetDataSource(int indx, string path){}
  62. public static bool WVPSourceIsReady(int indx){return false;}
  63. public static bool WVPSourcePlay(int indx){return false;}
  64. public static void WVPSourceStop(int indx){}
  65. public static void WVPSourcePause(int indx){}
  66. public static void WVPSourceRelease(int indx){}
  67. public static bool WVPSourceIsPlaying(int indx){return false;}
  68. public static float WVPSourceDuration(int indx){return 0;}
  69. public static bool WVPSourceIsMute(int indx){return false;}
  70. public static void WVPSourceSetMute(int indx, bool mute){}
  71. public static void WVPSourceSetLoop(int indx, bool loop){}
  72. public static int WVPSourceWidth(int indx){return -1;}
  73. public static int WVPSourceHeight(int indx){return -1;}
  74. public static double WVPSourceFrameTime(int indx){return 0;}
  75. public static void WVPSourceSetFrameTime(int indx, double timeInSec){}
  76. #endif
  77. }
  78. }