NullMediaPlayer.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System;
  2. using UnityEngine;
  3. namespace RenderHeads.Media.AVProVideo
  4. {
  5. public sealed class NullMediaPlayer : BaseMediaPlayer
  6. {
  7. public override string GetVersion()
  8. {
  9. return "0.0.0";
  10. }
  11. public override bool OpenVideoFromFile(string path, long offset, string httpHeaderJson)
  12. {
  13. this._texture_AVPro = (Texture2D)Resources.Load("AVPro");
  14. this._texture_AVPro1 = (Texture2D)Resources.Load("AVPro1");
  15. if (this._texture_AVPro)
  16. {
  17. this._Width = this._texture_AVPro.width;
  18. this._height = this._texture_AVPro.height;
  19. }
  20. this._texture = this._texture_AVPro;
  21. this._fakeFlipTime = 0f;
  22. this._frameCount = 0;
  23. return true;
  24. }
  25. public override void CloseVideo()
  26. {
  27. this._frameCount = 0;
  28. Resources.UnloadAsset(this._texture_AVPro);
  29. Resources.UnloadAsset(this._texture_AVPro1);
  30. }
  31. public override void SetLooping(bool bLooping)
  32. {
  33. this._bLoop = bLooping;
  34. }
  35. public override bool IsLooping()
  36. {
  37. return this._bLoop;
  38. }
  39. public override bool HasMetaData()
  40. {
  41. return true;
  42. }
  43. public override bool CanPlay()
  44. {
  45. return true;
  46. }
  47. public override bool HasAudio()
  48. {
  49. return false;
  50. }
  51. public override bool HasVideo()
  52. {
  53. return false;
  54. }
  55. public override void Play()
  56. {
  57. this._isPlaying = true;
  58. this._isPaused = false;
  59. this._fakeFlipTime = 0f;
  60. }
  61. public override void Pause()
  62. {
  63. this._isPlaying = false;
  64. this._isPaused = true;
  65. }
  66. public override void Stop()
  67. {
  68. this._isPlaying = false;
  69. this._isPaused = false;
  70. }
  71. public override bool IsSeeking()
  72. {
  73. return false;
  74. }
  75. public override bool IsPlaying()
  76. {
  77. return this._isPlaying;
  78. }
  79. public override bool IsPaused()
  80. {
  81. return this._isPaused;
  82. }
  83. public override bool IsFinished()
  84. {
  85. return this._isPlaying && this._currentTime >= this.GetDurationMs();
  86. }
  87. public override bool IsBuffering()
  88. {
  89. return false;
  90. }
  91. public override float GetDurationMs()
  92. {
  93. return 10000f;
  94. }
  95. public override int GetVideoWidth()
  96. {
  97. return this._Width;
  98. }
  99. public override int GetVideoHeight()
  100. {
  101. return this._height;
  102. }
  103. public override float GetVideoDisplayRate()
  104. {
  105. return 10f;
  106. }
  107. public override Texture GetTexture(int index)
  108. {
  109. return this._texture;
  110. }
  111. public override int GetTextureFrameCount()
  112. {
  113. return this._frameCount;
  114. }
  115. public override bool RequiresVerticalFlip()
  116. {
  117. return false;
  118. }
  119. public override void Rewind()
  120. {
  121. this.Seek(0f);
  122. }
  123. public override void Seek(float timeMs)
  124. {
  125. this._currentTime = timeMs;
  126. }
  127. public override void SeekFast(float timeMs)
  128. {
  129. this._currentTime = timeMs;
  130. }
  131. public override float GetCurrentTimeMs()
  132. {
  133. return this._currentTime;
  134. }
  135. public override void SetPlaybackRate(float rate)
  136. {
  137. this._playbackRate = rate;
  138. }
  139. public override float GetPlaybackRate()
  140. {
  141. return this._playbackRate;
  142. }
  143. public override float GetBufferingProgress()
  144. {
  145. return 0f;
  146. }
  147. public override void MuteAudio(bool bMuted)
  148. {
  149. }
  150. public override bool IsMuted()
  151. {
  152. return true;
  153. }
  154. public override void SetVolume(float volume)
  155. {
  156. this._volume = volume;
  157. }
  158. public override float GetVolume()
  159. {
  160. return this._volume;
  161. }
  162. public override int GetAudioTrackCount()
  163. {
  164. return 0;
  165. }
  166. public override int GetCurrentAudioTrack()
  167. {
  168. return 0;
  169. }
  170. public override void SetAudioTrack(int index)
  171. {
  172. }
  173. public override int GetVideoTrackCount()
  174. {
  175. return 0;
  176. }
  177. public override int GetCurrentVideoTrack()
  178. {
  179. return 0;
  180. }
  181. public override string GetCurrentAudioTrackId()
  182. {
  183. return string.Empty;
  184. }
  185. public override int GetCurrentAudioTrackBitrate()
  186. {
  187. return 0;
  188. }
  189. public override void SetVideoTrack(int index)
  190. {
  191. }
  192. public override string GetCurrentVideoTrackId()
  193. {
  194. return string.Empty;
  195. }
  196. public override int GetCurrentVideoTrackBitrate()
  197. {
  198. return 0;
  199. }
  200. public override float GetVideoFrameRate()
  201. {
  202. return 0f;
  203. }
  204. public override void Update()
  205. {
  206. this.UpdateSubtitles();
  207. if (this._isPlaying)
  208. {
  209. this._currentTime += Time.deltaTime * 1000f;
  210. if (this._currentTime >= this.GetDurationMs())
  211. {
  212. this._currentTime = this.GetDurationMs();
  213. if (this._bLoop)
  214. {
  215. this.Rewind();
  216. }
  217. }
  218. this._fakeFlipTime += Time.deltaTime;
  219. if ((double)this._fakeFlipTime >= 0.1)
  220. {
  221. this._fakeFlipTime = 0f;
  222. this._texture = ((!(this._texture == this._texture_AVPro)) ? this._texture_AVPro : this._texture_AVPro1);
  223. this._frameCount++;
  224. }
  225. }
  226. }
  227. public override void Render()
  228. {
  229. }
  230. public override void Dispose()
  231. {
  232. }
  233. private bool _isPlaying;
  234. private bool _isPaused;
  235. private float _currentTime;
  236. private float _volume;
  237. private float _playbackRate = 1f;
  238. private bool _bLoop;
  239. private int _Width = 256;
  240. private int _height = 256;
  241. private Texture2D _texture;
  242. private Texture2D _texture_AVPro;
  243. private Texture2D _texture_AVPro1;
  244. private float _fakeFlipTime;
  245. private int _frameCount;
  246. private const float FrameRate = 10f;
  247. }
  248. }