PageRenderTime 7982ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/ninja_association.swf_as/br/com/stimuli/loading/loadingtypes/VideoItem.as

https://gitlab.com/nshit/clan-panel-old
ActionScript | 249 lines | 225 code | 24 blank | 0 comment | 29 complexity | 2ec0afe7d1f5c30f9055b3b5ecd28e20 MD5 | raw file
  1. package br.com.stimuli.loading.loadingtypes
  2. {
  3. import br.com.stimuli.loading.*;
  4. import flash.display.*;
  5. import flash.events.*;
  6. import flash.net.*;
  7. import flash.utils.*;
  8. public class VideoItem extends br.com.stimuli.loading.loadingtypes.LoadingItem
  9. {
  10. public function VideoItem(arg1:flash.net.URLRequest, arg2:String, arg3:String)
  11. {
  12. specificAvailableProps = [br.com.stimuli.loading.BulkLoader.CHECK_POLICY_FILE, br.com.stimuli.loading.BulkLoader.PAUSED_AT_START];
  13. super(arg1, arg2, arg3);
  14. return;
  15. }
  16. public override function _parseOptions(arg1:Object):Array
  17. {
  18. this.pausedAtStart = arg1[br.com.stimuli.loading.BulkLoader.PAUSED_AT_START] || false;
  19. this._checkPolicyFile = arg1[br.com.stimuli.loading.BulkLoader.CHECK_POLICY_FILE] || false;
  20. return super._parseOptions(arg1);
  21. }
  22. public override function load():void
  23. {
  24. var customClient:Object;
  25. var loc1:*;
  26. super.load();
  27. this.nc = new flash.net.NetConnection();
  28. this.nc.connect(null);
  29. this.stream = new flash.net.NetStream(this.nc);
  30. this.stream.addEventListener(flash.events.IOErrorEvent.IO_ERROR, onErrorHandler, false, 0, true);
  31. this.stream.addEventListener(flash.events.NetStatusEvent.NET_STATUS, this.onNetStatus, false, 0, true);
  32. this.dummyEventTrigger = new flash.display.Sprite();
  33. this.dummyEventTrigger.addEventListener(flash.events.Event.ENTER_FRAME, this.createNetStreamEvent, false, 0, true);
  34. customClient = new Object();
  35. customClient.onCuePoint = function (... rest):void
  36. {
  37. return;
  38. }
  39. customClient.onMetaData = this.onVideoMetadata;
  40. customClient.onPlayStatus = function (... rest):void
  41. {
  42. return;
  43. }
  44. this.stream.client = customClient;
  45. this.stream.play(url.url, this._checkPolicyFile);
  46. this.stream.seek(0);
  47. return;
  48. }
  49. public function createNetStreamEvent(arg1:flash.events.Event):void
  50. {
  51. var loc1:*;
  52. loc1 = null;
  53. var loc2:*;
  54. loc2 = null;
  55. var loc3:*;
  56. loc3 = null;
  57. var loc4:*;
  58. loc4 = 0;
  59. var loc5:*;
  60. loc5 = NaN;
  61. var loc6:*;
  62. loc6 = NaN;
  63. var loc7:*;
  64. loc7 = NaN;
  65. if (_bytesTotal == _bytesLoaded && _bytesTotal > 8)
  66. {
  67. if (this.dummyEventTrigger)
  68. {
  69. this.dummyEventTrigger.removeEventListener(flash.events.Event.ENTER_FRAME, this.createNetStreamEvent, false);
  70. }
  71. loc1 = new flash.events.Event(flash.events.Event.COMPLETE);
  72. this.onCompleteHandler(loc1);
  73. }
  74. else
  75. {
  76. if (_bytesTotal == 0 && this.stream.bytesTotal > 4)
  77. {
  78. loc2 = new flash.events.Event(flash.events.Event.OPEN);
  79. this.onStartedHandler(loc2);
  80. _bytesLoaded = this.stream.bytesLoaded;
  81. _bytesTotal = this.stream.bytesTotal;
  82. }
  83. else
  84. {
  85. if (this.stream)
  86. {
  87. loc3 = new flash.events.ProgressEvent(flash.events.ProgressEvent.PROGRESS, false, false, this.stream.bytesLoaded, this.stream.bytesTotal);
  88. if (this.isVideo() && this.metaData && !this._canBeginStreaming)
  89. {
  90. loc4 = flash.utils.getTimer() - responseTime;
  91. loc5 = bytesLoaded / (loc4 / 1000);
  92. loc6 = _bytesRemaining / (loc5 * 0.8);
  93. if ((loc7 = this.metaData.duration - this.stream.bufferLength) > loc6)
  94. {
  95. this.fireCanBeginStreamingEvent();
  96. }
  97. }
  98. super.onProgressHandler(loc3);
  99. }
  100. }
  101. }
  102. return;
  103. }
  104. public override function onCompleteHandler(arg1:flash.events.Event):void
  105. {
  106. _content = this.stream;
  107. super.onCompleteHandler(arg1);
  108. return;
  109. }
  110. public override function onStartedHandler(arg1:flash.events.Event):void
  111. {
  112. _content = this.stream;
  113. if (this.pausedAtStart && this.stream)
  114. {
  115. this.stream.pause();
  116. }
  117. super.onStartedHandler(arg1);
  118. return;
  119. }
  120. public override function stop():void
  121. {
  122. try
  123. {
  124. if (this.stream)
  125. {
  126. this.stream.close();
  127. }
  128. }
  129. catch (e:Error)
  130. {
  131. };
  132. super.stop();
  133. return;
  134. }
  135. public override function cleanListeners():void
  136. {
  137. if (this.stream)
  138. {
  139. this.stream.removeEventListener(flash.events.IOErrorEvent.IO_ERROR, onErrorHandler, false);
  140. this.stream.removeEventListener(flash.events.NetStatusEvent.NET_STATUS, this.onNetStatus, false);
  141. }
  142. if (this.dummyEventTrigger)
  143. {
  144. this.dummyEventTrigger.removeEventListener(flash.events.Event.ENTER_FRAME, this.createNetStreamEvent, false);
  145. this.dummyEventTrigger = null;
  146. }
  147. return;
  148. }
  149. public override function isVideo():Boolean
  150. {
  151. return true;
  152. }
  153. public override function isStreamable():Boolean
  154. {
  155. return true;
  156. }
  157. public override function destroy():void
  158. {
  159. if (!this.stream)
  160. {
  161. };
  162. this.stop();
  163. this.cleanListeners();
  164. this.stream = null;
  165. super.destroy();
  166. return;
  167. }
  168. function onNetStatus(arg1:flash.events.NetStatusEvent):void
  169. {
  170. var loc1:*;
  171. loc1 = null;
  172. if (!this.stream)
  173. {
  174. return;
  175. }
  176. this.stream.removeEventListener(flash.events.NetStatusEvent.NET_STATUS, this.onNetStatus, false);
  177. if (arg1.info.code != "NetStream.Play.Start")
  178. {
  179. if (arg1.info.code == "NetStream.Play.StreamNotFound")
  180. {
  181. onErrorHandler(arg1);
  182. }
  183. }
  184. else
  185. {
  186. _content = this.stream;
  187. loc1 = new flash.events.Event(flash.events.Event.OPEN);
  188. this.onStartedHandler(loc1);
  189. }
  190. return;
  191. }
  192. function onVideoMetadata(arg1:*):void
  193. {
  194. this._metaData = arg1;
  195. return;
  196. }
  197. public function get metaData():Object
  198. {
  199. return this._metaData;
  200. }
  201. public function get checkPolicyFile():Object
  202. {
  203. return this._checkPolicyFile;
  204. }
  205. private function fireCanBeginStreamingEvent():void
  206. {
  207. if (this._canBeginStreaming)
  208. {
  209. return;
  210. }
  211. this._canBeginStreaming = true;
  212. var loc1:*;
  213. loc1 = new flash.events.Event(br.com.stimuli.loading.BulkLoader.CAN_BEGIN_PLAYING);
  214. dispatchEvent(loc1);
  215. return;
  216. }
  217. private var nc:flash.net.NetConnection;
  218. var stream:flash.net.NetStream;
  219. private var dummyEventTrigger:flash.display.Sprite;
  220. private var _checkPolicyFile:Boolean;
  221. var pausedAtStart:Boolean=false;
  222. private var _metaData:Object;
  223. private var _canBeginStreaming:Boolean=false;
  224. }
  225. }