xgplayer 2.32.5 → 2.32.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/browser/controls/airplay.js +1 -1
  2. package/browser/controls/cssFullscreen.js +1 -1
  3. package/browser/controls/danmu.js +3 -1
  4. package/browser/controls/definition.js +1 -1
  5. package/browser/controls/download.js +1 -1
  6. package/browser/controls/enter.js +1 -1
  7. package/browser/controls/error.js +1 -1
  8. package/browser/controls/errorRetry.js +1 -1
  9. package/browser/controls/flex.js +1 -1
  10. package/browser/controls/fullscreen.js +1 -1
  11. package/browser/controls/loading.js +1 -1
  12. package/browser/controls/memoryPlay.js +1 -1
  13. package/browser/controls/miniplayer.js +9 -7
  14. package/browser/controls/mobile.js +1 -1
  15. package/browser/controls/nativeTextTrack.js +1 -1
  16. package/browser/controls/pc.js +1 -1
  17. package/browser/controls/pip.js +1 -1
  18. package/browser/controls/play.js +1 -1
  19. package/browser/controls/playNext.js +1 -1
  20. package/browser/controls/playbackRate.js +1 -1
  21. package/browser/controls/poster.js +1 -1
  22. package/browser/controls/progress.js +1 -1
  23. package/browser/controls/reload.js +1 -1
  24. package/browser/controls/replay.js +1 -1
  25. package/browser/controls/rotate.js +1 -1
  26. package/browser/controls/screenShot.js +1 -1
  27. package/browser/controls/start.js +1 -1
  28. package/browser/controls/textTrack.js +1 -1
  29. package/browser/controls/time.js +1 -1
  30. package/browser/controls/volume.js +1 -1
  31. package/browser/core_player.js +1 -1
  32. package/browser/core_player.js.map +1 -1
  33. package/browser/index.js +11 -7
  34. package/browser/index.js.map +1 -1
  35. package/browser/simple_player.js +1 -1
  36. package/browser/simple_player.js.map +1 -1
  37. package/dist/controls/airplay.js +1 -1
  38. package/dist/controls/cssFullscreen.js +1 -1
  39. package/dist/controls/danmu.js +3 -1
  40. package/dist/controls/definition.js +1 -1
  41. package/dist/controls/download.js +1 -1
  42. package/dist/controls/enter.js +1 -1
  43. package/dist/controls/error.js +1 -1
  44. package/dist/controls/errorRetry.js +1 -1
  45. package/dist/controls/flex.js +1 -1
  46. package/dist/controls/fullscreen.js +1 -1
  47. package/dist/controls/loading.js +1 -1
  48. package/dist/controls/memoryPlay.js +1 -1
  49. package/dist/controls/miniplayer.js +9 -7
  50. package/dist/controls/mobile.js +1 -1
  51. package/dist/controls/nativeTextTrack.js +1 -1
  52. package/dist/controls/pc.js +1 -1
  53. package/dist/controls/pip.js +1 -1
  54. package/dist/controls/play.js +1 -1
  55. package/dist/controls/playNext.js +1 -1
  56. package/dist/controls/playbackRate.js +1 -1
  57. package/dist/controls/poster.js +1 -1
  58. package/dist/controls/progress.js +1 -1
  59. package/dist/controls/reload.js +1 -1
  60. package/dist/controls/replay.js +1 -1
  61. package/dist/controls/rotate.js +1 -1
  62. package/dist/controls/screenShot.js +1 -1
  63. package/dist/controls/start.js +1 -1
  64. package/dist/controls/textTrack.js +1 -1
  65. package/dist/controls/time.js +1 -1
  66. package/dist/controls/volume.js +1 -1
  67. package/dist/core_player.js +2960 -2889
  68. package/dist/core_player.js.map +1 -1
  69. package/dist/index.js +1938 -3321
  70. package/dist/index.js.map +1 -1
  71. package/dist/index.min.css +1 -0
  72. package/dist/index.min.js +2 -0
  73. package/dist/index.min.js.map +1 -0
  74. package/dist/simple_player.js +274 -281
  75. package/dist/simple_player.js.map +1 -1
  76. package/es/_virtual/_rollupPluginBabelHelpers.js +216 -0
  77. package/es/constant.d.ts +4 -0
  78. package/es/constant.js +5 -0
  79. package/es/controls/airplay.js +1 -1
  80. package/es/controls/cssFullscreen.js +1 -1
  81. package/es/controls/danmu.js +3 -1
  82. package/es/controls/definition.js +1 -1
  83. package/es/controls/download.js +1 -1
  84. package/es/controls/enter.js +1 -1
  85. package/es/controls/error.js +1 -1
  86. package/es/controls/errorRetry.js +1 -1
  87. package/es/controls/flex.js +1 -1
  88. package/es/controls/fullscreen.js +1 -1
  89. package/es/controls/i18n.js +1 -1
  90. package/es/controls/keyboard.js +1 -1
  91. package/es/controls/loading.js +1 -1
  92. package/es/controls/localPreview.js +1 -1
  93. package/es/controls/memoryPlay.js +1 -1
  94. package/es/controls/miniplayer.js +9 -7
  95. package/es/controls/mobile.js +1 -1
  96. package/es/controls/nativeTextTrack.js +1 -1
  97. package/es/controls/pc.js +1 -1
  98. package/es/controls/pip.js +1 -1
  99. package/es/controls/play.js +1 -1
  100. package/es/controls/playNext.js +1 -1
  101. package/es/controls/playbackRate.js +1 -1
  102. package/es/controls/poster.js +1 -1
  103. package/es/controls/progress.js +1 -1
  104. package/es/controls/reload.js +1 -1
  105. package/es/controls/replay.js +1 -1
  106. package/es/controls/rotate.js +1 -1
  107. package/es/controls/screenShot.js +1 -1
  108. package/es/controls/start.js +1 -1
  109. package/es/controls/textTrack.js +1 -1
  110. package/es/controls/time.js +1 -1
  111. package/es/controls/volume.js +1 -1
  112. package/es/core_player.js +1 -1
  113. package/es/core_player.js.map +1 -1
  114. package/es/defaultConfig.d.ts +243 -0
  115. package/es/defaultConfig.js +85 -0
  116. package/es/error.d.ts +114 -0
  117. package/es/error.js +75 -0
  118. package/es/events.d.ts +61 -0
  119. package/es/events.js +62 -0
  120. package/es/icons.d.ts +2 -0
  121. package/es/index.css +499 -0
  122. package/es/index.d.ts +25 -0
  123. package/es/index.js +11 -7
  124. package/es/index.js.map +1 -1
  125. package/es/index.scss +29 -0
  126. package/es/index.umd.d.ts +60 -0
  127. package/es/index.umd.js +30 -0
  128. package/es/lang/en.d.ts +91 -0
  129. package/es/lang/en.js +77 -0
  130. package/es/lang/i18n.d.ts +36 -0
  131. package/es/lang/i18n.js +122 -0
  132. package/es/lang/index.d.ts +2 -0
  133. package/es/lang/jp.d.ts +91 -0
  134. package/es/lang/jp.js +77 -0
  135. package/es/lang/zh-cn.d.ts +91 -0
  136. package/es/lang/zh-cn.js +77 -0
  137. package/es/lang/zh-hk.d.ts +91 -0
  138. package/es/lang/zh-hk.js +77 -0
  139. package/es/mediaProxy.d.ts +334 -0
  140. package/es/mediaProxy.js +623 -0
  141. package/es/player.d.ts +825 -0
  142. package/es/player.js +1945 -0
  143. package/es/plugin/basePlugin.d.ts +180 -0
  144. package/es/plugin/basePlugin.js +259 -0
  145. package/es/plugin/hooksDescriptor.d.ts +60 -0
  146. package/es/plugin/hooksDescriptor.js +149 -0
  147. package/es/plugin/index.d.ts +13 -0
  148. package/es/plugin/plugin.d.ts +207 -0
  149. package/es/plugin/plugin.js +542 -0
  150. package/es/plugin/pluginsManager.d.ts +162 -0
  151. package/es/plugin/pluginsManager.js +362 -0
  152. package/es/plugin/preset.d.ts +1 -0
  153. package/es/plugin/preset.js +28 -0
  154. package/es/plugin/resizeObserver.d.ts +3 -0
  155. package/es/plugin/resizeObserver.js +108 -0
  156. package/es/plugins/assets/back.js +4 -0
  157. package/es/plugins/assets/download.js +4 -0
  158. package/es/plugins/assets/exitCssFull.js +4 -0
  159. package/es/plugins/assets/exitFull.js +4 -0
  160. package/es/plugins/assets/loading.js +4 -0
  161. package/es/plugins/assets/panel.js +4 -0
  162. package/es/plugins/assets/pause.js +4 -0
  163. package/es/plugins/assets/pipIcon.js +4 -0
  164. package/es/plugins/assets/pipIconExit.js +4 -0
  165. package/es/plugins/assets/play.js +4 -0
  166. package/es/plugins/assets/playNext.js +4 -0
  167. package/es/plugins/assets/replay.js +4 -0
  168. package/es/plugins/assets/requestCssFull.js +7 -0
  169. package/es/plugins/assets/requestFull.js +4 -0
  170. package/es/plugins/assets/rotate.js +4 -0
  171. package/es/plugins/assets/seekicon.js +4 -0
  172. package/es/plugins/assets/volumeLarge.js +4 -0
  173. package/es/plugins/assets/volumeMuted.js +4 -0
  174. package/es/plugins/assets/volumeSmall.js +4 -0
  175. package/es/plugins/common/iconPlugin.d.ts +5 -0
  176. package/es/plugins/common/iconPlugin.js +42 -0
  177. package/es/plugins/common/iconTools.d.ts +1 -0
  178. package/es/plugins/common/iconTools.js +8 -0
  179. package/es/plugins/common/index.scss +2 -0
  180. package/es/plugins/common/optionList.d.ts +15 -0
  181. package/es/plugins/common/optionList.js +120 -0
  182. package/es/plugins/common/optionsIcon.d.ts +40 -0
  183. package/es/plugins/common/optionsIcon.js +304 -0
  184. package/es/plugins/common/optionsIcon.scss +154 -0
  185. package/es/plugins/common/thumbnail.d.ts +62 -0
  186. package/es/plugins/common/thumbnail.js +191 -0
  187. package/es/plugins/common/thumbnail.scss +27 -0
  188. package/es/plugins/controls/index.css +132 -0
  189. package/es/plugins/controls/index.d.ts +73 -0
  190. package/es/plugins/controls/index.js +189 -0
  191. package/es/plugins/controls/index.scss +204 -0
  192. package/es/plugins/cssFullScreen/index.css +12 -0
  193. package/es/plugins/cssFullScreen/index.d.ts +40 -0
  194. package/es/plugins/cssFullScreen/index.js +136 -0
  195. package/es/plugins/cssFullScreen/index.scss +19 -0
  196. package/es/plugins/danmu/danmuIcon.d.ts +24 -0
  197. package/es/plugins/danmu/danmuIcon.js +98 -0
  198. package/es/plugins/danmu/danmuPanel.d.ts +39 -0
  199. package/es/plugins/danmu/danmuPanel.js +81 -0
  200. package/es/plugins/danmu/index.css +603 -0
  201. package/es/plugins/danmu/index.d.ts +96 -0
  202. package/es/plugins/danmu/index.js +313 -0
  203. package/es/plugins/danmu/index.scss +356 -0
  204. package/es/plugins/definition/index.css +4 -0
  205. package/es/plugins/definition/index.d.ts +38 -0
  206. package/es/plugins/definition/index.js +164 -0
  207. package/es/plugins/definition/index.scss +4 -0
  208. package/es/plugins/download/index.css +13 -0
  209. package/es/plugins/download/index.d.ts +31 -0
  210. package/es/plugins/download/index.js +107 -0
  211. package/es/plugins/download/index.scss +22 -0
  212. package/es/plugins/dynamicBg/index.css +16 -0
  213. package/es/plugins/dynamicBg/index.d.ts +83 -0
  214. package/es/plugins/dynamicBg/index.js +316 -0
  215. package/es/plugins/dynamicBg/index.scss +19 -0
  216. package/es/plugins/enter/index.css +104 -0
  217. package/es/plugins/enter/index.d.ts +19 -0
  218. package/es/plugins/enter/index.js +46 -0
  219. package/es/plugins/enter/index.scss +78 -0
  220. package/es/plugins/error/index.css +29 -0
  221. package/es/plugins/error/index.d.ts +8 -0
  222. package/es/plugins/error/index.js +75 -0
  223. package/es/plugins/error/index.scss +34 -0
  224. package/es/plugins/fpsDetect/index.d.ts +34 -0
  225. package/es/plugins/fpsDetect/index.js +149 -0
  226. package/es/plugins/fullscreen/backicon.d.ts +17 -0
  227. package/es/plugins/fullscreen/backicon.js +72 -0
  228. package/es/plugins/fullscreen/index.css +23 -0
  229. package/es/plugins/fullscreen/index.d.ts +58 -0
  230. package/es/plugins/fullscreen/index.js +202 -0
  231. package/es/plugins/fullscreen/index.scss +35 -0
  232. package/es/plugins/gapJump/index.d.ts +21 -0
  233. package/es/plugins/gapJump/index.js +142 -0
  234. package/es/plugins/keyboard/index.d.ts +89 -0
  235. package/es/plugins/keyboard/index.js +421 -0
  236. package/es/plugins/loading/index.css +58 -0
  237. package/es/plugins/loading/index.d.ts +11 -0
  238. package/es/plugins/loading/index.js +43 -0
  239. package/es/plugins/loading/index.scss +70 -0
  240. package/es/plugins/logger/index.d.ts +54 -0
  241. package/es/plugins/logger/index.js +311 -0
  242. package/es/plugins/miniScreen/index.css +179 -0
  243. package/es/plugins/miniScreen/index.d.ts +68 -0
  244. package/es/plugins/miniScreen/index.js +212 -0
  245. package/es/plugins/miniScreen/index.scss +198 -0
  246. package/es/plugins/miniScreen/miniScreenIcon.d.ts +11 -0
  247. package/es/plugins/miniScreen/miniScreenIcon.js +56 -0
  248. package/es/plugins/mobile/index.css +181 -0
  249. package/es/plugins/mobile/index.d.ts +125 -0
  250. package/es/plugins/mobile/index.js +631 -0
  251. package/es/plugins/mobile/index.scss +180 -0
  252. package/es/plugins/mobile/touch.d.ts +43 -0
  253. package/es/plugins/mobile/touch.js +214 -0
  254. package/es/plugins/netAdaption/index.d.ts +5 -0
  255. package/es/plugins/pc/index.css +3 -0
  256. package/es/plugins/pc/index.d.ts +14 -0
  257. package/es/plugins/pc/index.js +199 -0
  258. package/es/plugins/pc/index.scss +5 -0
  259. package/es/plugins/pip/index.css +12 -0
  260. package/es/plugins/pip/index.d.ts +37 -0
  261. package/es/plugins/pip/index.js +222 -0
  262. package/es/plugins/pip/index.scss +21 -0
  263. package/es/plugins/play/index.css +12 -0
  264. package/es/plugins/play/index.d.ts +23 -0
  265. package/es/plugins/play/index.js +127 -0
  266. package/es/plugins/play/index.scss +18 -0
  267. package/es/plugins/playNext/index.css +22 -0
  268. package/es/plugins/playNext/index.d.ts +19 -0
  269. package/es/plugins/playNext/index.js +104 -0
  270. package/es/plugins/playNext/index.scss +35 -0
  271. package/es/plugins/playbackRate/index.css +4 -0
  272. package/es/plugins/playbackRate/index.d.ts +31 -0
  273. package/es/plugins/playbackRate/index.js +140 -0
  274. package/es/plugins/playbackRate/index.scss +6 -0
  275. package/es/plugins/poster/index.css +39 -0
  276. package/es/plugins/poster/index.d.ts +27 -0
  277. package/es/plugins/poster/index.js +109 -0
  278. package/es/plugins/poster/index.scss +56 -0
  279. package/es/plugins/progress/index.css +234 -0
  280. package/es/plugins/progress/index.d.ts +178 -0
  281. package/es/plugins/progress/index.js +687 -0
  282. package/es/plugins/progress/index.scss +288 -0
  283. package/es/plugins/progress/innerList.d.ts +49 -0
  284. package/es/plugins/progress/innerList.js +285 -0
  285. package/es/plugins/progress/miniProgress.d.ts +9 -0
  286. package/es/plugins/progress/miniProgress.js +55 -0
  287. package/es/plugins/progressPreview/dotsApi.d.ts +1 -0
  288. package/es/plugins/progressPreview/dotsApi.js +269 -0
  289. package/es/plugins/progressPreview/index.css +190 -0
  290. package/es/plugins/progressPreview/index.d.ts +87 -0
  291. package/es/plugins/progressPreview/index.js +475 -0
  292. package/es/plugins/progressPreview/index.scss +235 -0
  293. package/es/plugins/prompt/index.css +47 -0
  294. package/es/plugins/prompt/index.d.ts +24 -0
  295. package/es/plugins/prompt/index.js +110 -0
  296. package/es/plugins/prompt/index.scss +53 -0
  297. package/es/plugins/replay/index.css +33 -0
  298. package/es/plugins/replay/index.d.ts +16 -0
  299. package/es/plugins/replay/index.js +109 -0
  300. package/es/plugins/replay/index.scss +41 -0
  301. package/es/plugins/rotate/index.css +0 -0
  302. package/es/plugins/rotate/index.d.ts +22 -0
  303. package/es/plugins/rotate/index.js +148 -0
  304. package/es/plugins/rotate/index.scss +0 -0
  305. package/es/plugins/rotate/index2.js +2 -0
  306. package/es/plugins/screenShot/index.css +3 -0
  307. package/es/plugins/screenShot/index.d.ts +30 -0
  308. package/es/plugins/screenShot/index.js +178 -0
  309. package/es/plugins/screenShot/index.scss +5 -0
  310. package/es/plugins/start/index.css +91 -0
  311. package/es/plugins/start/index.d.ts +41 -0
  312. package/es/plugins/start/index.js +267 -0
  313. package/es/plugins/start/index.scss +115 -0
  314. package/es/plugins/stats/index.d.ts +38 -0
  315. package/es/plugins/stats/index.js +194 -0
  316. package/es/plugins/testspeed/index.d.ts +26 -0
  317. package/es/plugins/testspeed/index.js +207 -0
  318. package/es/plugins/time/index.css +46 -0
  319. package/es/plugins/time/index.d.ts +28 -0
  320. package/es/plugins/time/index.js +225 -0
  321. package/es/plugins/time/index.scss +57 -0
  322. package/es/plugins/time/timesegments.d.ts +24 -0
  323. package/es/plugins/time/timesegments.js +216 -0
  324. package/es/plugins/track/index.css +91 -0
  325. package/es/plugins/track/index.d.ts +132 -0
  326. package/es/plugins/track/index.js +463 -0
  327. package/es/plugins/track/index.scss +111 -0
  328. package/es/plugins/track/nativeSubTitle.d.ts +22 -0
  329. package/es/plugins/track/nativeSubTitle.js +94 -0
  330. package/es/plugins/volume/index.css +95 -0
  331. package/es/plugins/volume/index.d.ts +88 -0
  332. package/es/plugins/volume/index.js +319 -0
  333. package/es/plugins/volume/index.scss +124 -0
  334. package/es/plugins/waitingTimeoutJump/index.d.ts +15 -0
  335. package/es/plugins/waitingTimeoutJump/index.js +88 -0
  336. package/es/presets/default-en.d.ts +33 -0
  337. package/es/presets/default-en.js +63 -0
  338. package/es/presets/default.d.ts +34 -0
  339. package/es/presets/default.js +70 -0
  340. package/es/presets/index.d.ts +4 -0
  341. package/es/presets/live.d.ts +94 -0
  342. package/es/presets/live.js +39 -0
  343. package/es/presets/mobile.d.ts +103 -0
  344. package/es/presets/mobile.js +34 -0
  345. package/es/simple_player.js +1 -1
  346. package/es/simple_player.js.map +1 -1
  347. package/es/state.d.ts +11 -0
  348. package/es/state.js +12 -0
  349. package/es/stateClassMap.d.ts +32 -0
  350. package/es/stateClassMap.js +32 -0
  351. package/es/style/common/animation.scss +16 -0
  352. package/es/style/common/svg-url.scss +70 -0
  353. package/es/style/common.scss +457 -0
  354. package/es/style/index.scss +4 -0
  355. package/es/style/variable.scss +76 -0
  356. package/es/utils/database.d.ts +31 -0
  357. package/es/utils/database.js +107 -0
  358. package/es/utils/debug.d.ts +10 -0
  359. package/es/utils/debug.js +43 -0
  360. package/es/utils/draggabilly.d.ts +54 -0
  361. package/es/utils/draggabilly.js +410 -0
  362. package/es/utils/sniffer.d.ts +28 -0
  363. package/es/utils/sniffer.js +150 -0
  364. package/es/utils/url.d.ts +1 -0
  365. package/es/utils/util.d.ts +304 -0
  366. package/es/utils/util.js +827 -0
  367. package/es/utils/xgplayerTimeRange.d.ts +7 -0
  368. package/es/utils/xgplayerTimeRange.js +25 -0
  369. package/es/version.d.ts +2 -0
  370. package/es/version.js +2 -0
  371. package/package.json +2 -3
@@ -0,0 +1,623 @@
1
+ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, createClass as _createClass, defineProperty as _defineProperty, get as _get, getPrototypeOf as _getPrototypeOf } from "./_virtual/_rollupPluginBabelHelpers.js";
2
+ import EventEmitter from "eventemitter3";
3
+ import util from "./utils/util.js";
4
+ import sniffer from "./utils/sniffer.js";
5
+ import Errors, { ERROR_TYPE_MAP } from "./error.js";
6
+ import { VIDEO_EVENTS, SOURCE_SUCCESS, SOURCE_ERROR, URL_CHANGE, WAITING } from "./events.js";
7
+ function emitVideoEvent(eventKey, e) {
8
+ if (!this || !this.emit) {
9
+ return;
10
+ }
11
+ if (eventKey === "error") {
12
+ this.errorHandler(eventKey, e.error);
13
+ } else {
14
+ this.emit(eventKey, e);
15
+ }
16
+ }
17
+ function getVideoEventHandler(eventKey, player) {
18
+ return function(e, _err) {
19
+ var eData = {
20
+ player,
21
+ eventName: eventKey,
22
+ originalEvent: e,
23
+ detail: e.detail || {},
24
+ timeStamp: e.timeStamp,
25
+ currentTime: player.currentTime,
26
+ duration: player.duration,
27
+ paused: player.paused,
28
+ ended: player.ended,
29
+ isInternalOp: !!player._internalOp[e.type],
30
+ muted: player.muted,
31
+ volume: player.volume,
32
+ host: util.getHostFromUrl(player.currentSrc),
33
+ vtype: player.vtype
34
+ };
35
+ player.removeInnerOP(e.type);
36
+ if (eventKey === "timeupdate") {
37
+ player._currentTime = player.media && player.media.currentTime;
38
+ }
39
+ if (eventKey === "ratechange") {
40
+ var _rate = player.media ? player.media.playbackRate : 0;
41
+ if (_rate && player._rate === _rate) {
42
+ return;
43
+ }
44
+ player._rate = player.media && player.media.playbackRate;
45
+ }
46
+ if (eventKey === "durationchange") {
47
+ player._duration = player.media.duration;
48
+ }
49
+ if (eventKey === "volumechange") {
50
+ eData.isMutedChange = player._lastMuted !== player.muted;
51
+ player._lastMuted = player.muted;
52
+ }
53
+ if (eventKey === "error") {
54
+ eData.error = _err || player.video.error;
55
+ }
56
+ if (player.mediaEventMiddleware[eventKey]) {
57
+ var callback = emitVideoEvent.bind(player, eventKey, eData);
58
+ try {
59
+ player.mediaEventMiddleware[eventKey].call(player, eData, callback);
60
+ } catch (err) {
61
+ emitVideoEvent.call(player, eventKey, eData);
62
+ throw err;
63
+ }
64
+ } else {
65
+ emitVideoEvent.call(player, eventKey, eData);
66
+ }
67
+ };
68
+ }
69
+ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
70
+ _inherits(MediaProxy2, _EventEmitter);
71
+ var _super = _createSuper(MediaProxy2);
72
+ function MediaProxy2(options) {
73
+ var _this;
74
+ _classCallCheck(this, MediaProxy2);
75
+ _this = _super.call(this, options);
76
+ _this._hasStart = false;
77
+ _this._currentTime = 0;
78
+ _this._duration = 0;
79
+ _this._internalOp = {};
80
+ _this._lastMuted = false;
81
+ _this.vtype = "MP4";
82
+ _this._rate = -1;
83
+ _this.mediaConfig = Object.assign({}, {
84
+ controls: false,
85
+ autoplay: options.autoplay,
86
+ playsinline: options.playsinline,
87
+ "x5-playsinline": options.playsinline,
88
+ "webkit-playsinline": options.playsinline,
89
+ "x5-video-player-fullscreen": options["x5-video-player-fullscreen"] || options.x5VideoPlayerFullscreen,
90
+ "x5-video-orientation": options["x5-video-orientation"] || options.x5VideoOrientation,
91
+ airplay: options.airplay,
92
+ "webkit-airplay": options.airplay,
93
+ tabindex: options.tabindex | 0,
94
+ mediaType: options.mediaType || "video",
95
+ "data-index": -1
96
+ }, options.videoConfig, options.videoAttributes);
97
+ var playerType = options["x5-video-player-type"] || options.x5VideoPlayerType;
98
+ if (sniffer.isWeixin && sniffer.os.isAndroid && playerType) {
99
+ _this.mediaConfig["x5-video-player-type"] = playerType;
100
+ delete _this.mediaConfig.playsinline;
101
+ delete _this.mediaConfig["webkit-playsinline"];
102
+ delete _this.mediaConfig["x5-playsinline"];
103
+ }
104
+ if (options.loop) {
105
+ _this.mediaConfig.loop = "loop";
106
+ }
107
+ if (options.autoplayMuted && !Object.prototype.hasOwnProperty.call(_this.mediaConfig, "muted")) {
108
+ _this.mediaConfig.muted = true;
109
+ }
110
+ _this.media = util.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
111
+ if (options.defaultPlaybackRate) {
112
+ _this.media.defaultPlaybackRate = _this.media.playbackRate = options.defaultPlaybackRate;
113
+ }
114
+ if (util.typeOf(options.volume) === "Number") {
115
+ _this.volume = options.volume;
116
+ }
117
+ if (options.autoplayMuted) {
118
+ _this.media.muted = true;
119
+ _this._lastMuted = true;
120
+ }
121
+ if (options.autoplay) {
122
+ _this.media.autoplay = true;
123
+ }
124
+ _this._interval = {};
125
+ _this.mediaEventMiddleware = {};
126
+ _this.attachVideoEvents();
127
+ return _this;
128
+ }
129
+ _createClass(MediaProxy2, [{
130
+ key: "setEventsMiddleware",
131
+ value: function setEventsMiddleware(middlewares) {
132
+ var _this2 = this;
133
+ Object.keys(middlewares).map(function(key) {
134
+ _this2.mediaEventMiddleware[key] = middlewares[key];
135
+ });
136
+ }
137
+ }, {
138
+ key: "removeEventsMiddleware",
139
+ value: function removeEventsMiddleware(middlewares) {
140
+ var _this3 = this;
141
+ Object.keys(middlewares).map(function(key) {
142
+ delete _this3.mediaEventMiddleware[key];
143
+ });
144
+ }
145
+ }, {
146
+ key: "attachVideoEvents",
147
+ value: function attachVideoEvents() {
148
+ var _this4 = this;
149
+ var media = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.media;
150
+ if (!this._evHandlers) {
151
+ this._evHandlers = VIDEO_EVENTS.map(function(eventKey) {
152
+ var funName = "on".concat(eventKey.charAt(0).toUpperCase()).concat(eventKey.slice(1));
153
+ if (typeof _this4[funName] === "function") {
154
+ _this4.on(eventKey, _this4[funName]);
155
+ }
156
+ return _defineProperty({}, eventKey, getVideoEventHandler(eventKey, _this4));
157
+ });
158
+ }
159
+ this._evHandlers.forEach(function(item) {
160
+ var eventKey = Object.keys(item)[0];
161
+ media.addEventListener(eventKey, item[eventKey], false);
162
+ });
163
+ }
164
+ }, {
165
+ key: "detachVideoEvents",
166
+ value: function detachVideoEvents() {
167
+ var _this5 = this;
168
+ var media = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.media;
169
+ this._evHandlers.forEach(function(item) {
170
+ var eventKey = Object.keys(item)[0];
171
+ media.removeEventListener(eventKey, item[eventKey], false);
172
+ });
173
+ this._evHandlers.forEach(function(item) {
174
+ var eventKey = Object.keys(item)[0];
175
+ var funName = "on".concat(eventKey.charAt(0).toUpperCase()).concat(eventKey.slice(1));
176
+ if (typeof _this5[funName] === "function") {
177
+ _this5.off(eventKey, _this5[funName]);
178
+ }
179
+ });
180
+ this._evHandlers = null;
181
+ }
182
+ }, {
183
+ key: "_attachSourceEvents",
184
+ value: function _attachSourceEvents(video, urls) {
185
+ var _this6 = this;
186
+ video.removeAttribute("src");
187
+ video.load();
188
+ urls.forEach(function(item, index) {
189
+ _this6.media.appendChild(util.createDom("source", "", {
190
+ src: "".concat(item.src),
191
+ type: "".concat(item.type || ""),
192
+ "data-index": index + 1
193
+ }));
194
+ });
195
+ var _c = video.children;
196
+ if (!_c) {
197
+ return;
198
+ }
199
+ this._videoSourceCount = _c.length;
200
+ this._videoSourceIndex = _c.length;
201
+ this._vLoadeddata = function(e) {
202
+ _this6.emit(SOURCE_SUCCESS, {
203
+ src: e.target.currentSrc,
204
+ host: util.getHostFromUrl(e.target.currentSrc)
205
+ });
206
+ };
207
+ var _eHandler = null;
208
+ for (var i = 0; i < this._evHandlers.length; i++) {
209
+ if (Object.keys(this._evHandlers[i])[0] === "error") {
210
+ _eHandler = this._evHandlers[i];
211
+ break;
212
+ }
213
+ }
214
+ !this._sourceError && (this._sourceError = function(e) {
215
+ var _dIndex = parseInt(e.target.getAttribute("data-index"), 10);
216
+ _this6._videoSourceIndex--;
217
+ if (_this6._videoSourceIndex === 0 || _dIndex >= _this6._videoSourceCount) {
218
+ var _err = {
219
+ code: 4,
220
+ message: "sources_load_error"
221
+ };
222
+ _eHandler ? _eHandler.error(e, _err) : _this6.errorHandler("error", _err);
223
+ }
224
+ var type = ERROR_TYPE_MAP[4];
225
+ _this6.emit(SOURCE_ERROR, new Errors(_this6, {
226
+ errorType: type,
227
+ errorCode: 4,
228
+ errorMessage: "sources_load_error",
229
+ mediaError: {
230
+ code: 4,
231
+ message: "sources_load_error"
232
+ },
233
+ src: e.target.src
234
+ }));
235
+ });
236
+ for (var _i = 0; _i < _c.length; _i++) {
237
+ _c[_i].addEventListener("error", this._sourceError);
238
+ }
239
+ video.addEventListener("loadeddata", this._vLoadeddata);
240
+ }
241
+ }, {
242
+ key: "_detachSourceEvents",
243
+ value: function _detachSourceEvents(video) {
244
+ var _c = video.children;
245
+ if (!_c || _c.length === 0 || !this._sourceError) {
246
+ return;
247
+ }
248
+ for (var i = 0; i < _c.length; i++) {
249
+ _c[i].removeEventListener("error", this._sourceError);
250
+ }
251
+ while (_c.length > 0) {
252
+ video.removeChild(_c[0]);
253
+ }
254
+ this._vLoadeddata && video.removeEventListener("loadeddata", this._vLoadeddata);
255
+ }
256
+ }, {
257
+ key: "errorHandler",
258
+ value: function errorHandler(name) {
259
+ var error = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
260
+ if (this.media && (this.media.error || error)) {
261
+ var _e = this.media.error || error;
262
+ var type = _e.code ? ERROR_TYPE_MAP[_e.code] : "other";
263
+ var message = _e.message;
264
+ if (!this.media.currentSrc) {
265
+ message = "empty_src";
266
+ _e = {
267
+ code: 6,
268
+ message
269
+ };
270
+ }
271
+ this.emit(name, new Errors(this, {
272
+ errorType: type,
273
+ errorCode: _e.code,
274
+ errorMessage: _e.message || "",
275
+ mediaError: _e
276
+ }));
277
+ }
278
+ }
279
+ }, {
280
+ key: "destroy",
281
+ value: function destroy() {
282
+ if (this.media) {
283
+ if (this.media.pause) {
284
+ this.media.pause();
285
+ this.media.muted = true;
286
+ }
287
+ this.media.removeAttribute("src");
288
+ this.media.load();
289
+ }
290
+ this._currentTime = 0;
291
+ this._duration = 0;
292
+ this.mediaConfig = null;
293
+ for (var k in this._interval) {
294
+ if (Object.prototype.hasOwnProperty.call(this._interval, k)) {
295
+ clearInterval(this._interval[k]);
296
+ this._interval[k] = null;
297
+ }
298
+ }
299
+ this.detachVideoEvents();
300
+ this.media = null;
301
+ this.mediaEventMiddleware = {};
302
+ this.removeAllListeners();
303
+ }
304
+ }, {
305
+ key: "video",
306
+ get: function get() {
307
+ return this.media;
308
+ },
309
+ set: function set(media) {
310
+ this.media = media;
311
+ }
312
+ }, {
313
+ key: "play",
314
+ value: function play() {
315
+ var ret = this.media ? this.media.play() : null;
316
+ return ret;
317
+ }
318
+ }, {
319
+ key: "pause",
320
+ value: function pause() {
321
+ this.media && this.media.pause();
322
+ }
323
+ }, {
324
+ key: "load",
325
+ value: function load() {
326
+ this.media && this.media.load();
327
+ }
328
+ }, {
329
+ key: "canPlayType",
330
+ value: function canPlayType(type) {
331
+ return this.media ? this.media.canPlayType(type) : false;
332
+ }
333
+ }, {
334
+ key: "getBufferedRange",
335
+ value: function getBufferedRange(buffered) {
336
+ var range = [0, 0];
337
+ if (!this.media) {
338
+ return range;
339
+ }
340
+ if (!buffered) {
341
+ buffered = this.media.buffered;
342
+ }
343
+ var currentTime = this.media.currentTime;
344
+ if (buffered) {
345
+ for (var i = 0, len = buffered.length; i < len; i++) {
346
+ range[0] = buffered.start(i);
347
+ range[1] = buffered.end(i);
348
+ if (range[0] <= currentTime && currentTime <= range[1]) {
349
+ break;
350
+ }
351
+ }
352
+ }
353
+ if (range[0] - currentTime <= 0 && currentTime - range[1] <= 0) {
354
+ return range;
355
+ } else {
356
+ return [0, 0];
357
+ }
358
+ }
359
+ }, {
360
+ key: "autoplay",
361
+ get: function get() {
362
+ return this.media ? this.media.autoplay : false;
363
+ },
364
+ set: function set(isTrue) {
365
+ this.media && (this.media.autoplay = isTrue);
366
+ }
367
+ }, {
368
+ key: "buffered",
369
+ get: function get() {
370
+ return this.media ? this.media.buffered : null;
371
+ }
372
+ }, {
373
+ key: "buffered2",
374
+ get: function get() {
375
+ return this.media && this.media.buffered ? util.getBuffered2(this.media.buffered) : null;
376
+ }
377
+ }, {
378
+ key: "bufferedPoint",
379
+ get: function get() {
380
+ var ret = {
381
+ start: 0,
382
+ end: 0
383
+ };
384
+ if (!this.media) {
385
+ return ret;
386
+ }
387
+ var _buffered = this.media.buffered;
388
+ if (!_buffered || _buffered.length === 0) {
389
+ return ret;
390
+ }
391
+ for (var i = 0; i < _buffered.length; i++) {
392
+ if ((_buffered.start(i) <= this.currentTime || _buffered.start(i) < 0.1) && _buffered.end(i) >= this.currentTime) {
393
+ return {
394
+ start: _buffered.start(i),
395
+ end: _buffered.end(i)
396
+ };
397
+ }
398
+ }
399
+ return ret;
400
+ }
401
+ }, {
402
+ key: "crossOrigin",
403
+ get: function get() {
404
+ return this.media ? this.media.crossOrigin : "";
405
+ },
406
+ set: function set(isTrue) {
407
+ this.media && (this.media.crossOrigin = isTrue);
408
+ }
409
+ }, {
410
+ key: "currentSrc",
411
+ get: function get() {
412
+ return this.media ? this.media.currentSrc : "";
413
+ },
414
+ set: function set(src) {
415
+ this.media && (this.media.currentSrc = src);
416
+ }
417
+ }, {
418
+ key: "currentTime",
419
+ get: function get() {
420
+ if (!this.media) {
421
+ return 0;
422
+ }
423
+ return this.media.currentTime !== void 0 ? this.media.currentTime : this._currentTime;
424
+ },
425
+ set: function set(time) {
426
+ this.media && (this.media.currentTime = time);
427
+ }
428
+ }, {
429
+ key: "defaultMuted",
430
+ get: function get() {
431
+ return this.media ? this.media.defaultMuted : false;
432
+ },
433
+ set: function set(isTrue) {
434
+ this.media && (this.media.defaultMuted = isTrue);
435
+ }
436
+ }, {
437
+ key: "duration",
438
+ get: function get() {
439
+ return this._duration;
440
+ }
441
+ }, {
442
+ key: "ended",
443
+ get: function get() {
444
+ return this.media ? this.media.ended : false;
445
+ }
446
+ }, {
447
+ key: "error",
448
+ get: function get() {
449
+ return this.media.error;
450
+ }
451
+ }, {
452
+ key: "errorNote",
453
+ get: function get() {
454
+ var err = this.media.error;
455
+ if (!err) {
456
+ return "";
457
+ }
458
+ var status = ["MEDIA_ERR_ABORTED", "MEDIA_ERR_NETWORK", "MEDIA_ERR_DECODE", "MEDIA_ERR_SRC_NOT_SUPPORTED"];
459
+ return status[this.media.error.code - 1];
460
+ }
461
+ }, {
462
+ key: "loop",
463
+ get: function get() {
464
+ return this.media ? this.media.loop : false;
465
+ },
466
+ set: function set(isTrue) {
467
+ this.media && (this.media.loop = isTrue);
468
+ }
469
+ }, {
470
+ key: "muted",
471
+ get: function get() {
472
+ return this.media ? this.media.muted : false;
473
+ },
474
+ set: function set(isTrue) {
475
+ if (!this.media || this.media.muted === isTrue) {
476
+ return;
477
+ }
478
+ this._lastMuted = this.media.muted;
479
+ this.media.muted = isTrue;
480
+ }
481
+ }, {
482
+ key: "networkState",
483
+ get: function get() {
484
+ return this.media.networkState;
485
+ }
486
+ }, {
487
+ key: "paused",
488
+ get: function get() {
489
+ return this.media ? this.media.paused : true;
490
+ }
491
+ }, {
492
+ key: "playbackRate",
493
+ get: function get() {
494
+ return this.media ? this.media.playbackRate : 0;
495
+ },
496
+ set: function set(rate) {
497
+ if (!this.media || rate === Infinity) {
498
+ return;
499
+ }
500
+ this.media.defaultPlaybackRate = rate;
501
+ this.media.playbackRate = rate;
502
+ }
503
+ }, {
504
+ key: "played",
505
+ get: function get() {
506
+ return this.media ? this.media.played : null;
507
+ }
508
+ }, {
509
+ key: "preload",
510
+ get: function get() {
511
+ return this.media ? this.media.preload : false;
512
+ },
513
+ set: function set(isTrue) {
514
+ this.media && (this.media.preload = isTrue);
515
+ }
516
+ }, {
517
+ key: "readyState",
518
+ get: function get() {
519
+ return this.media.readyState;
520
+ }
521
+ }, {
522
+ key: "seekable",
523
+ get: function get() {
524
+ return this.media ? this.media.seekable : false;
525
+ }
526
+ }, {
527
+ key: "seeking",
528
+ get: function get() {
529
+ return this.media ? this.media.seeking : false;
530
+ }
531
+ }, {
532
+ key: "src",
533
+ get: function get() {
534
+ return this.media ? this.media.src : "";
535
+ },
536
+ set: function set(url) {
537
+ if (!this.media) {
538
+ return;
539
+ }
540
+ this.emit(URL_CHANGE, url);
541
+ this.emit(WAITING);
542
+ this._currentTime = 0;
543
+ this._duration = 0;
544
+ if (util.isMSE(this.media)) {
545
+ this.onWaiting();
546
+ return;
547
+ }
548
+ this._detachSourceEvents(this.media);
549
+ if (util.typeOf(url) === "Array") {
550
+ this._attachSourceEvents(this.media, url);
551
+ } else if (url) {
552
+ this.media.src = url;
553
+ } else {
554
+ this.media.removeAttribute("src");
555
+ }
556
+ this.load();
557
+ }
558
+ }, {
559
+ key: "volume",
560
+ get: function get() {
561
+ return this.media ? this.media.volume : 0;
562
+ },
563
+ set: function set(vol) {
564
+ if (vol === Infinity || !this.media) {
565
+ return;
566
+ }
567
+ this.media.volume = vol;
568
+ }
569
+ }, {
570
+ key: "addInnerOP",
571
+ value: function addInnerOP(event) {
572
+ this._internalOp[event] = true;
573
+ }
574
+ }, {
575
+ key: "removeInnerOP",
576
+ value: function removeInnerOP(event) {
577
+ delete this._internalOp[event];
578
+ }
579
+ }, {
580
+ key: "emit",
581
+ value: function emit(event, data) {
582
+ var _get2;
583
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
584
+ args[_key - 2] = arguments[_key];
585
+ }
586
+ (_get2 = _get(_getPrototypeOf(MediaProxy2.prototype), "emit", this)).call.apply(_get2, [this, event, data].concat(args));
587
+ }
588
+ }, {
589
+ key: "on",
590
+ value: function on(event, callback) {
591
+ var _get3;
592
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
593
+ args[_key2 - 2] = arguments[_key2];
594
+ }
595
+ (_get3 = _get(_getPrototypeOf(MediaProxy2.prototype), "on", this)).call.apply(_get3, [this, event, callback].concat(args));
596
+ }
597
+ }, {
598
+ key: "once",
599
+ value: function once(event, callback) {
600
+ var _get4;
601
+ for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
602
+ args[_key3 - 2] = arguments[_key3];
603
+ }
604
+ (_get4 = _get(_getPrototypeOf(MediaProxy2.prototype), "once", this)).call.apply(_get4, [this, event, callback].concat(args));
605
+ }
606
+ }, {
607
+ key: "off",
608
+ value: function off(event, callback) {
609
+ var _get5;
610
+ for (var _len4 = arguments.length, args = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
611
+ args[_key4 - 2] = arguments[_key4];
612
+ }
613
+ (_get5 = _get(_getPrototypeOf(MediaProxy2.prototype), "off", this)).call.apply(_get5, [this, event, callback].concat(args));
614
+ }
615
+ }, {
616
+ key: "offAll",
617
+ value: function offAll() {
618
+ _get(_getPrototypeOf(MediaProxy2.prototype), "removeAllListeners", this).call(this);
619
+ }
620
+ }]);
621
+ return MediaProxy2;
622
+ }(EventEmitter);
623
+ export { MediaProxy as default };