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
package/es/player.js ADDED
@@ -0,0 +1,1945 @@
1
+ import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, assertThisInitialized as _assertThisInitialized, possibleConstructorReturn as _possibleConstructorReturn, get as _get, getPrototypeOf as _getPrototypeOf, objectSpread2 as _objectSpread2 } from "./_virtual/_rollupPluginBabelHelpers.js";
2
+ import MediaProxy from "./mediaProxy.js";
3
+ import util, { checkIsCurrentVideo } from "./utils/util.js";
4
+ export { default as Util } from "./utils/util.js";
5
+ import sniffer from "./utils/sniffer.js";
6
+ export { default as Sniffer } from "./utils/sniffer.js";
7
+ import INDEXDB from "./utils/database.js";
8
+ import Errors from "./error.js";
9
+ export { default as Errors } from "./error.js";
10
+ import { CANPLAY, USER_ACTION, FULLSCREEN_CHANGE, READY, ERROR, LOADED_DATA, PLAY, URL_NULL, COMPLETE, AUTOPLAY_STARTED, AUTOPLAY_PREVENTED, SEEKED, DEFINITION_CHANGE, AFTER_DEFINITION_CHANGE, RESET, DESTROY, CSS_FULLSCREEN_CHANGE, PLAYER_FOCUS, PLAYER_BLUR, VIDEO_RESIZE, REPLAY, PLAYNEXT } from "./events.js";
11
+ import * as events from "./events.js";
12
+ export { events as Events };
13
+ import { PLATER_ID, FULLSCREEN_EVENTS, GET_FULLSCREEN_API, EXIT_FULLSCREEN_API } from "./constant.js";
14
+ import { POSITIONS } from "./plugin/plugin.js";
15
+ export { default as Plugin } from "./plugin/plugin.js";
16
+ import BasePlugin from "./plugin/basePlugin.js";
17
+ export { default as BasePlugin } from "./plugin/basePlugin.js";
18
+ import pluginsManager from "./plugin/pluginsManager.js";
19
+ import STATE_CLASS from "./stateClassMap.js";
20
+ export { default as STATE_CLASS } from "./stateClassMap.js";
21
+ import getDefaultConfig from "./defaultConfig.js";
22
+ import { usePreset } from "./plugin/preset.js";
23
+ import hooksDescriptor, { runHooks, delHooksDescriptor, hook, useHooks, removeHooks, usePluginHooks, removePluginHooks } from "./plugin/hooksDescriptor.js";
24
+ import Controls from "./plugins/controls/index.js";
25
+ import XG_DEBUG, { bindDebug } from "./utils/debug.js";
26
+ import I18N from "./lang/i18n.js";
27
+ export { default as I18N } from "./lang/i18n.js";
28
+ import version from "./version.js";
29
+ import { STATES, STATE_ARRAY } from "./state.js";
30
+ var PlAYER_HOOKS = ["play", "pause", "replay", "retry"];
31
+ var REAL_TIME_SPEED = 0;
32
+ var AVG_SPEED = 0;
33
+ var Player = /* @__PURE__ */ function(_MediaProxy) {
34
+ _inherits(Player2, _MediaProxy);
35
+ var _super = _createSuper(Player2);
36
+ function Player2(options) {
37
+ var _this;
38
+ _classCallCheck(this, Player2);
39
+ var _config = util.deepMerge(getDefaultConfig(), options);
40
+ _this = _super.call(this, _config);
41
+ _defineProperty(_assertThisInitialized(_this), "canPlayFunc", function() {
42
+ if (!_this.config) {
43
+ return;
44
+ }
45
+ var _this$config = _this.config, autoplay = _this$config.autoplay, startTime = _this$config.startTime, defaultPlaybackRate = _this$config.defaultPlaybackRate;
46
+ XG_DEBUG.logInfo("player", "canPlayFunc, startTime", startTime);
47
+ if (startTime) {
48
+ _this.currentTime = startTime > _this.duration ? _this.duration : startTime;
49
+ _this.config.startTime = 0;
50
+ }
51
+ _this.playbackRate = defaultPlaybackRate;
52
+ (autoplay || _this._useAutoplay) && _this.mediaPlay();
53
+ _this.off(CANPLAY, _this.canPlayFunc);
54
+ _this.removeClass(STATE_CLASS.ENTER);
55
+ });
56
+ _defineProperty(_assertThisInitialized(_this), "onFullscreenChange", function(event, isFullScreen) {
57
+ var delayResize = function delayResize2() {
58
+ util.setTimeout(_assertThisInitialized(_this), function() {
59
+ _this.resize();
60
+ }, 100);
61
+ };
62
+ var fullEl = util.getFullScreenEl();
63
+ if (_this._fullActionFrom) {
64
+ _this._fullActionFrom = "";
65
+ } else {
66
+ _this.emit(USER_ACTION, {
67
+ eventType: "system",
68
+ action: "switch_fullscreen",
69
+ pluginName: "player",
70
+ currentTime: _this.currentTime,
71
+ duration: _this.duration,
72
+ props: [{
73
+ prop: "fullscreen",
74
+ from: true,
75
+ to: false
76
+ }]
77
+ });
78
+ }
79
+ var isVideo = checkIsCurrentVideo(fullEl, _this.playerId, PLATER_ID);
80
+ if (isFullScreen || fullEl && (fullEl === _this._fullscreenEl || isVideo)) {
81
+ delayResize();
82
+ !_this.config.closeFocusVideoFocus && _this.media.focus();
83
+ _this.fullscreen = true;
84
+ _this.changeFullStyle(_this.root, fullEl, STATE_CLASS.FULLSCREEN);
85
+ _this.emit(FULLSCREEN_CHANGE, true, _this._fullScreenOffset);
86
+ if (_this.cssfullscreen) {
87
+ _this.exitCssFullscreen();
88
+ }
89
+ } else if (_this.fullscreen) {
90
+ delayResize();
91
+ var _assertThisInitialize = _assertThisInitialized(_this), _fullScreenOffset = _assertThisInitialize._fullScreenOffset, config = _assertThisInitialize.config;
92
+ if (config.needFullscreenScroll) {
93
+ window.scrollTo(_fullScreenOffset.left, _fullScreenOffset.top);
94
+ util.setTimeout(_assertThisInitialized(_this), function() {
95
+ _this.fullscreen = false;
96
+ _this._fullScreenOffset = null;
97
+ }, 100);
98
+ } else {
99
+ !_this.config.closeFocusVideoFocus && _this.media.focus();
100
+ _this.fullscreen = false;
101
+ _this._fullScreenOffset = null;
102
+ }
103
+ if (!_this.cssfullscreen) {
104
+ _this.recoverFullStyle(_this.root, _this._fullscreenEl, STATE_CLASS.FULLSCREEN);
105
+ } else {
106
+ _this.removeClass(STATE_CLASS.FULLSCREEN);
107
+ }
108
+ _this._fullscreenEl = null;
109
+ _this.emit(FULLSCREEN_CHANGE, false);
110
+ }
111
+ });
112
+ _defineProperty(_assertThisInitialized(_this), "_onWebkitbeginfullscreen", function(e) {
113
+ _this._fullscreenEl = _this.media;
114
+ _this.onFullscreenChange(e, true);
115
+ });
116
+ _defineProperty(_assertThisInitialized(_this), "_onWebkitendfullscreen", function(e) {
117
+ _this.onFullscreenChange(e, false);
118
+ });
119
+ hooksDescriptor(_assertThisInitialized(_this), PlAYER_HOOKS);
120
+ _this.config = _config;
121
+ _this._pluginInfoId = util.generateSessionId();
122
+ bindDebug(_assertThisInitialized(_this));
123
+ var defaultPreset = _this.constructor.defaultPreset;
124
+ if (_this.config.presets.length) {
125
+ var defaultIdx = _this.config.presets.indexOf("default");
126
+ if (defaultIdx >= 0 && defaultPreset) {
127
+ _this.config.presets[defaultIdx] = defaultPreset;
128
+ }
129
+ } else if (defaultPreset) {
130
+ _this.config.presets.push(defaultPreset);
131
+ }
132
+ _this.userTimer = null;
133
+ _this.waitTimer = null;
134
+ _this._state = STATES.INITIAL;
135
+ _this.isError = false;
136
+ _this._hasStart = false;
137
+ _this.isSeeking = false;
138
+ _this.isCanplay = false;
139
+ _this._useAutoplay = false;
140
+ _this.rotateDeg = 0;
141
+ _this.isActive = false;
142
+ _this.fullscreen = false;
143
+ _this.cssfullscreen = false;
144
+ _this.isRotateFullscreen = false;
145
+ _this._fullscreenEl = null;
146
+ _this.timeSegments = [];
147
+ _this._cssfullscreenEl = null;
148
+ _this.curDefinition = null;
149
+ _this._orgCss = "";
150
+ _this._fullScreenOffset = null;
151
+ _this._videoHeight = 0;
152
+ _this._videoWidth = 0;
153
+ _this.videoPos = {
154
+ pi: 1,
155
+ scale: 0,
156
+ rotate: -1,
157
+ x: 0,
158
+ y: 0,
159
+ h: -1,
160
+ w: -1,
161
+ vy: 0,
162
+ vx: 0
163
+ };
164
+ _this.sizeInfo = {
165
+ width: 0,
166
+ height: 0,
167
+ left: 0,
168
+ top: 0
169
+ };
170
+ _this._accPlayed = {
171
+ t: 0,
172
+ acc: 0,
173
+ loopAcc: 0
174
+ };
175
+ _this._offsetInfo = {
176
+ currentTime: -1,
177
+ duration: 0
178
+ };
179
+ _this.innerContainer = null;
180
+ _this.controls = null;
181
+ _this.topBar = null;
182
+ _this.root = null;
183
+ _this.__i18n = I18N.init(_this._pluginInfoId);
184
+ if (sniffer.os.isAndroid && sniffer.osVersion > 0 && sniffer.osVersion < 6) {
185
+ _this.config.autoplay = false;
186
+ }
187
+ _this.database = new INDEXDB();
188
+ _this.isUserActive = false;
189
+ _this._onceSeekCanplay = null;
190
+ _this._isPauseBeforeSeek = 0;
191
+ _this.innerStates = {
192
+ isActiveLocked: false
193
+ };
194
+ var rootInit = _this._initDOM();
195
+ if (!rootInit) {
196
+ console.error(new Error("can't find the dom which id is ".concat(_this.config.id, " or this.config.el does not exist")));
197
+ return _possibleConstructorReturn(_this);
198
+ }
199
+ var _this$config2 = _this.config, _this$config2$definit = _this$config2.definition, definition = _this$config2$definit === void 0 ? {} : _this$config2$definit, url = _this$config2.url;
200
+ if (!url && definition.list && definition.list.length > 0) {
201
+ var defaultDefinitionObj = definition.list.find(function(e) {
202
+ return e.definition && e.definition === definition.defaultDefinition;
203
+ });
204
+ if (!defaultDefinitionObj) {
205
+ definition.defaultDefinition = definition.list[0].definition;
206
+ defaultDefinitionObj = definition.list[0];
207
+ }
208
+ _this.config.url = defaultDefinitionObj.url;
209
+ _this.curDefinition = defaultDefinitionObj;
210
+ }
211
+ _this._bindEvents();
212
+ _this._registerPresets();
213
+ _this._registerPlugins();
214
+ pluginsManager.onPluginsReady(_assertThisInitialized(_this));
215
+ _this.getInitDefinition();
216
+ _this.setState(STATES.READY);
217
+ util.setTimeout(_assertThisInitialized(_this), function() {
218
+ _this.emit(READY);
219
+ }, 0);
220
+ _this.onReady && _this.onReady();
221
+ if (_this.config.videoInit || _this.config.autoplay) {
222
+ if (!_this.hasStart || _this.state < STATES.ATTACHED) {
223
+ _this.start();
224
+ }
225
+ }
226
+ return _this;
227
+ }
228
+ _createClass(Player2, [{
229
+ key: "_initDOM",
230
+ value: function _initDOM() {
231
+ var _this2 = this;
232
+ this.root = this.config.id ? document.getElementById(this.config.id) : null;
233
+ if (!this.root) {
234
+ var el = this.config.el;
235
+ if (el && el.nodeType === 1) {
236
+ this.root = el;
237
+ } else {
238
+ this.emit(ERROR, new Errors("use", this.config.vid, {
239
+ line: 32,
240
+ handle: "Constructor",
241
+ msg: "container id can't be empty"
242
+ }));
243
+ console.error("this.confg.id or this.config.el can't be empty");
244
+ return false;
245
+ }
246
+ }
247
+ var ret = pluginsManager.checkPlayerRoot(this.root);
248
+ if (ret) {
249
+ XG_DEBUG.logWarn("The is an Player instance already exists in this.root, destroy it and reinitialize");
250
+ ret.destroy();
251
+ }
252
+ this.root.setAttribute(PLATER_ID, this.playerId);
253
+ pluginsManager.init(this);
254
+ this._initBaseDoms();
255
+ var XgVideoProxy = this.constructor.XgVideoProxy;
256
+ if (XgVideoProxy && this.mediaConfig.mediaType === XgVideoProxy.mediaType) {
257
+ var _el = this.innerContainer || this.root;
258
+ this.detachVideoEvents(this.media);
259
+ var _nVideo = new XgVideoProxy(_el, this.config, this.mediaConfig);
260
+ this.attachVideoEvents(_nVideo);
261
+ this.media = _nVideo;
262
+ }
263
+ this.media.setAttribute(PLATER_ID, this.playerId);
264
+ if (this.config.controls) {
265
+ var _root = this.config.controls.root || null;
266
+ var controls = pluginsManager.register(this, Controls, {
267
+ root: _root
268
+ });
269
+ this.controls = controls;
270
+ }
271
+ var device = this.config.isMobileSimulateMode === "mobile" ? "mobile" : sniffer.device;
272
+ this.addClass("".concat(STATE_CLASS.DEFAULT, " ").concat(STATE_CLASS.INACTIVE, " xgplayer-").concat(device, " ").concat(this.config.controls ? "" : STATE_CLASS.NO_CONTROLS));
273
+ if (this.config.autoplay) {
274
+ this.addClass(STATE_CLASS.ENTER);
275
+ } else {
276
+ this.addClass(STATE_CLASS.NO_START);
277
+ }
278
+ if (this.config.fluid) {
279
+ var _this$config3 = this.config, _width = _this$config3.width, _height = _this$config3.height;
280
+ if (typeof _width !== "number" || typeof _height !== "number") {
281
+ _width = 600;
282
+ _height = 337.5;
283
+ }
284
+ var style = {
285
+ width: "100%",
286
+ height: "0",
287
+ "max-width": "100%",
288
+ "padding-top": "".concat(_height * 100 / _width, "%")
289
+ };
290
+ Object.keys(style).forEach(function(key) {
291
+ _this2.root.style[key] = style[key];
292
+ });
293
+ } else {
294
+ ["width", "height"].forEach(function(key) {
295
+ if (_this2.config[key]) {
296
+ if (typeof _this2.config[key] !== "number") {
297
+ _this2.root.style[key] = _this2.config[key];
298
+ } else {
299
+ _this2.root.style[key] = "".concat(_this2.config[key], "px");
300
+ }
301
+ }
302
+ });
303
+ }
304
+ var _this$root$getBoundin = this.root.getBoundingClientRect(), width = _this$root$getBoundin.width, height = _this$root$getBoundin.height, left = _this$root$getBoundin.left, top = _this$root$getBoundin.top;
305
+ this.sizeInfo.width = width;
306
+ this.sizeInfo.height = height;
307
+ this.sizeInfo.left = left;
308
+ this.sizeInfo.top = top;
309
+ return true;
310
+ }
311
+ }, {
312
+ key: "_initBaseDoms",
313
+ value: function _initBaseDoms() {
314
+ this.topBar = null;
315
+ this.leftBar = null;
316
+ this.rightBar = null;
317
+ if (this.config.marginControls) {
318
+ this.innerContainer = util.createDom("xg-video-container", "", {
319
+ "data-index": -1
320
+ }, "xg-video-container");
321
+ this.root.appendChild(this.innerContainer);
322
+ }
323
+ }
324
+ }, {
325
+ key: "_bindEvents",
326
+ value: function _bindEvents() {
327
+ var _this3 = this;
328
+ ["focus", "blur"].forEach(function(item) {
329
+ _this3.on(item, _this3["on" + item.charAt(0).toUpperCase() + item.slice(1)]);
330
+ });
331
+ FULLSCREEN_EVENTS.forEach(function(item) {
332
+ document && document.addEventListener(item, _this3.onFullscreenChange);
333
+ });
334
+ if (sniffer.os.isIos) {
335
+ this.media.addEventListener("webkitbeginfullscreen", this._onWebkitbeginfullscreen);
336
+ this.media.addEventListener("webkitendfullscreen", this._onWebkitendfullscreen);
337
+ }
338
+ this.once(LOADED_DATA, this.resize);
339
+ this.playFunc = function() {
340
+ if (!_this3.config.closeFocusVideoFocus) {
341
+ _this3.media.focus();
342
+ }
343
+ };
344
+ this.once(PLAY, this.playFunc);
345
+ }
346
+ }, {
347
+ key: "_unbindEvents",
348
+ value: function _unbindEvents() {
349
+ var _this4 = this;
350
+ this.root.removeEventListener("mousemove", this.mousemoveFunc);
351
+ FULLSCREEN_EVENTS.forEach(function(item) {
352
+ document.removeEventListener(item, _this4.onFullscreenChange);
353
+ });
354
+ this.playFunc && this.off(PLAY, this.playFunc);
355
+ this.off(CANPLAY, this.canPlayFunc);
356
+ this.media.removeEventListener("webkitbeginfullscreen", this._onWebkitbeginfullscreen);
357
+ this.media.removeEventListener("webkitendfullscreen", this._onWebkitendfullscreen);
358
+ }
359
+ }, {
360
+ key: "_startInit",
361
+ value: function _startInit(url) {
362
+ var _this5 = this;
363
+ if (!this.media) {
364
+ return;
365
+ }
366
+ if (!url || url === "" || util.typeOf(url) === "Array" && url.length === 0) {
367
+ url = "";
368
+ this.emit(URL_NULL);
369
+ XG_DEBUG.logWarn("config.url is null, please get url and run player._startInit(url)");
370
+ if (this.config.nullUrlStart) {
371
+ return;
372
+ }
373
+ }
374
+ this._detachSourceEvents(this.media);
375
+ if (util.typeOf(url) === "Array" && url.length > 0) {
376
+ this._attachSourceEvents(this.media, url);
377
+ } else if (!this.media.src || this.media.src !== url) {
378
+ this.media.src = url;
379
+ } else if (!url) {
380
+ this.media.removeAttribute("src");
381
+ }
382
+ if (util.typeOf(this.config.volume) === "Number") {
383
+ this.volume = this.config.volume;
384
+ }
385
+ var _root = this.innerContainer ? this.innerContainer : this.root;
386
+ if (this.media instanceof window.Element && !_root.contains(this.media)) {
387
+ _root.insertBefore(this.media, _root.firstChild);
388
+ }
389
+ var readyState = this.media.readyState;
390
+ XG_DEBUG.logInfo("_startInit readyState", readyState);
391
+ if (this.config.autoplay) {
392
+ !util.isMSE(this.media) && this.load();
393
+ (sniffer.os.isIpad || sniffer.os.isPhone) && this.mediaPlay();
394
+ }
395
+ if (readyState >= 2) {
396
+ this.canPlayFunc();
397
+ } else {
398
+ this.once(CANPLAY, this.canPlayFunc);
399
+ }
400
+ if (!this.hasStart || this.state < STATES.ATTACHED) {
401
+ pluginsManager.afterInit(this);
402
+ }
403
+ this.hasStart = true;
404
+ this.setState(STATES.ATTACHED);
405
+ util.setTimeout(this, function() {
406
+ _this5.emit(COMPLETE);
407
+ }, 0);
408
+ }
409
+ }, {
410
+ key: "_registerPlugins",
411
+ value: function _registerPlugins() {
412
+ var _this6 = this;
413
+ var isInit = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
414
+ this._loadingPlugins = [];
415
+ var ignores = this.config.ignores || [];
416
+ var plugins = this.config.plugins || [];
417
+ var i18n = this.config.i18n || [];
418
+ isInit && I18N.extend(i18n, this.__i18n);
419
+ var ignoresStr = ignores.join("||").toLowerCase().split("||");
420
+ var cuPlugins = this.plugins;
421
+ plugins.forEach(function(plugin) {
422
+ try {
423
+ var pluginName = plugin.plugin ? plugin.plugin.pluginName : plugin.pluginName;
424
+ if (pluginName && ignoresStr.indexOf(pluginName.toLowerCase()) > -1) {
425
+ return null;
426
+ }
427
+ if (!isInit && cuPlugins[pluginName.toLowerCase()]) {
428
+ return;
429
+ }
430
+ if (plugin.lazy && plugin.loader) {
431
+ var loadingPlugin = pluginsManager.lazyRegister(_this6, plugin);
432
+ if (plugin.forceBeforeInit) {
433
+ loadingPlugin.then(function() {
434
+ _this6._loadingPlugins.splice(_this6._loadingPlugins.indexOf(loadingPlugin), 1);
435
+ }).catch(function(e) {
436
+ XG_DEBUG.logError("_registerPlugins:loadingPlugin", e);
437
+ _this6._loadingPlugins.splice(_this6._loadingPlugins.indexOf(loadingPlugin), 1);
438
+ });
439
+ _this6._loadingPlugins.push(loadingPlugin);
440
+ }
441
+ return;
442
+ }
443
+ return _this6.registerPlugin(plugin);
444
+ } catch (err) {
445
+ XG_DEBUG.logError("_registerPlugins:", err);
446
+ }
447
+ });
448
+ }
449
+ }, {
450
+ key: "_registerPresets",
451
+ value: function _registerPresets() {
452
+ var _this7 = this;
453
+ this.config.presets.forEach(function(preset) {
454
+ usePreset(_this7, preset);
455
+ });
456
+ }
457
+ }, {
458
+ key: "_getRootByPosition",
459
+ value: function _getRootByPosition(position) {
460
+ var _root = null;
461
+ switch (position) {
462
+ case POSITIONS.ROOT_RIGHT:
463
+ if (!this.rightBar) {
464
+ this.rightBar = util.createPositionBar("xg-right-bar", this.root);
465
+ }
466
+ _root = this.rightBar;
467
+ break;
468
+ case POSITIONS.ROOT_LEFT:
469
+ if (!this.leftBar) {
470
+ this.leftBar = util.createPositionBar("xg-left-bar", this.root);
471
+ }
472
+ _root = this.leftBar;
473
+ break;
474
+ case POSITIONS.ROOT_TOP:
475
+ if (!this.topBar) {
476
+ this.topBar = util.createPositionBar("xg-top-bar", this.root);
477
+ if (this.config.topBarAutoHide) {
478
+ util.addClass(this.topBar, STATE_CLASS.TOP_BAR_AUTOHIDE);
479
+ }
480
+ }
481
+ _root = this.topBar;
482
+ break;
483
+ default:
484
+ _root = this.innerContainer || this.root;
485
+ break;
486
+ }
487
+ return _root;
488
+ }
489
+ }, {
490
+ key: "registerPlugin",
491
+ value: function registerPlugin(plugin, config) {
492
+ var _retPlugin = pluginsManager.formatPluginInfo(plugin, config);
493
+ var PLUFGIN = _retPlugin.PLUFGIN, options = _retPlugin.options;
494
+ var plugins = this.config.plugins;
495
+ var exits = pluginsManager.checkPluginIfExits(PLUFGIN.pluginName, plugins);
496
+ !exits && plugins.push(PLUFGIN);
497
+ var _pConfig = pluginsManager.getRootByConfig(PLUFGIN.pluginName, this.config);
498
+ _pConfig.root && (options.root = _pConfig.root);
499
+ _pConfig.position && (options.position = _pConfig.position);
500
+ var position = options.position ? options.position : options.config && options.config.position || PLUFGIN.defaultConfig && PLUFGIN.defaultConfig.position;
501
+ if (!options.root && typeof position === "string" && position.indexOf("controls") > -1) {
502
+ return this.controls && this.controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
503
+ }
504
+ if (!options.root) {
505
+ options.root = this._getRootByPosition(position);
506
+ }
507
+ return pluginsManager.register(this, PLUFGIN, options);
508
+ }
509
+ }, {
510
+ key: "deregister",
511
+ value: function deregister(plugin) {
512
+ if (typeof plugin === "string") {
513
+ pluginsManager.unRegister(this, plugin);
514
+ } else if (plugin instanceof BasePlugin) {
515
+ pluginsManager.unRegister(this, plugin.pluginName);
516
+ }
517
+ }
518
+ }, {
519
+ key: "unRegisterPlugin",
520
+ value: function unRegisterPlugin(plugin) {
521
+ var removedFromConfig = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
522
+ this.deregister(plugin);
523
+ if (removedFromConfig) {
524
+ this.removePluginFromConfig(plugin);
525
+ }
526
+ }
527
+ }, {
528
+ key: "removePluginFromConfig",
529
+ value: function removePluginFromConfig(plugin) {
530
+ var pluginName;
531
+ if (typeof plugin === "string") {
532
+ pluginName = plugin;
533
+ } else if (plugin instanceof BasePlugin) {
534
+ pluginName = plugin.pluginName;
535
+ }
536
+ if (!pluginName) {
537
+ return;
538
+ }
539
+ for (var i = this.config.plugins.length - 1; i > -1; i--) {
540
+ var _plugin = this.config.plugins[i];
541
+ if (_plugin.pluginName.toLowerCase() === pluginName.toLowerCase()) {
542
+ this.config.plugins.splice(i, 1);
543
+ break;
544
+ }
545
+ }
546
+ }
547
+ }, {
548
+ key: "plugins",
549
+ get: function get() {
550
+ return pluginsManager.getPlugins(this);
551
+ }
552
+ }, {
553
+ key: "getPlugin",
554
+ value: function getPlugin(pluginName) {
555
+ var plugin = pluginsManager.findPlugin(this, pluginName);
556
+ return plugin && plugin.pluginName ? plugin : null;
557
+ }
558
+ }, {
559
+ key: "addClass",
560
+ value: function addClass(className) {
561
+ if (!this.root) {
562
+ return;
563
+ }
564
+ if (!util.hasClass(this.root, className)) {
565
+ util.addClass(this.root, className);
566
+ }
567
+ }
568
+ }, {
569
+ key: "removeClass",
570
+ value: function removeClass(className) {
571
+ if (!this.root) {
572
+ return;
573
+ }
574
+ util.removeClass(this.root, className);
575
+ }
576
+ }, {
577
+ key: "hasClass",
578
+ value: function hasClass(className) {
579
+ if (!this.root) {
580
+ return;
581
+ }
582
+ return util.hasClass(this.root, className);
583
+ }
584
+ }, {
585
+ key: "setAttribute",
586
+ value: function setAttribute(key, value) {
587
+ if (!this.root) {
588
+ return;
589
+ }
590
+ this.root.setAttribute(key, value);
591
+ }
592
+ }, {
593
+ key: "removeAttribute",
594
+ value: function removeAttribute(key, value) {
595
+ if (!this.root) {
596
+ return;
597
+ }
598
+ this.root.removeAttribute(key, value);
599
+ }
600
+ }, {
601
+ key: "start",
602
+ value: function start(url) {
603
+ var _this8 = this;
604
+ if (this.state > STATES.ATTACHING) {
605
+ return;
606
+ }
607
+ if (!url && !this.config.url) {
608
+ this.getInitDefinition();
609
+ }
610
+ this.hasStart = true;
611
+ this.setState(STATES.ATTACHING);
612
+ this._registerPlugins(false);
613
+ return pluginsManager.beforeInit(this).then(function() {
614
+ if (!_this8.config) {
615
+ return;
616
+ }
617
+ if (!url) {
618
+ url = _this8.url || _this8.config.url;
619
+ }
620
+ var _furl = _this8.preProcessUrl(url);
621
+ var ret = _this8._startInit(_furl.url);
622
+ return ret;
623
+ }).catch(function(e) {
624
+ e.fileName = "player";
625
+ e.lineNumber = "236";
626
+ XG_DEBUG.logError("start:beforeInit:", e);
627
+ throw e;
628
+ });
629
+ }
630
+ }, {
631
+ key: "switchURL",
632
+ value: function switchURL(url, options) {
633
+ var _this9 = this;
634
+ var _src = url;
635
+ if (util.typeOf(url) === "Object") {
636
+ _src = url.url;
637
+ }
638
+ _src = this.preProcessUrl(_src).url;
639
+ var curTime = this.currentTime;
640
+ var isPaused = this.paused && !this.isError;
641
+ this.src = _src;
642
+ return new Promise(function(resolve, reject) {
643
+ var _error = function _error2(e) {
644
+ _this9.off("timeupdate", _canplay);
645
+ _this9.off("canplay", _canplay);
646
+ reject(e);
647
+ };
648
+ var _canplay = function _canplay2() {
649
+ _this9.currentTime = curTime;
650
+ if (isPaused) {
651
+ _this9.pause();
652
+ }
653
+ _this9.off("error", _error);
654
+ resolve(true);
655
+ };
656
+ _this9.once("error", _error);
657
+ if (!_src) {
658
+ _this9.errorHandler("error", {
659
+ code: 6,
660
+ message: "empty_src"
661
+ });
662
+ return;
663
+ }
664
+ if (sniffer.os.isAndroid) {
665
+ _this9.once("timeupdate", _canplay);
666
+ } else {
667
+ _this9.once("canplay", _canplay);
668
+ }
669
+ _this9.play();
670
+ });
671
+ }
672
+ }, {
673
+ key: "videoPlay",
674
+ value: function videoPlay() {
675
+ this.mediaPlay();
676
+ }
677
+ }, {
678
+ key: "mediaPlay",
679
+ value: function mediaPlay() {
680
+ var _this10 = this;
681
+ if (!this.hasStart && this.state < STATES.ATTACHED) {
682
+ this.removeClass(STATE_CLASS.NO_START);
683
+ this.addClass(STATE_CLASS.ENTER);
684
+ this.start();
685
+ this._useAutoplay = true;
686
+ return;
687
+ }
688
+ if (this.state < STATES.RUNNING) {
689
+ this.removeClass(STATE_CLASS.NO_START);
690
+ !this.isCanplay && this.addClass(STATE_CLASS.ENTER);
691
+ }
692
+ var playPromise = _get(_getPrototypeOf(Player2.prototype), "play", this).call(this);
693
+ if (playPromise !== void 0 && playPromise && playPromise.then) {
694
+ playPromise.then(function() {
695
+ _this10.removeClass(STATE_CLASS.NOT_ALLOW_AUTOPLAY);
696
+ _this10.addClass(STATE_CLASS.PLAYING);
697
+ if (_this10.state < STATES.RUNNING) {
698
+ XG_DEBUG.logInfo(">>>>playPromise.then");
699
+ _this10.setState(STATES.RUNNING);
700
+ _this10.emit(AUTOPLAY_STARTED);
701
+ }
702
+ }).catch(function(e) {
703
+ XG_DEBUG.logWarn(">>>>playPromise.catch", e.name);
704
+ if (_this10.media && _this10.media.error) {
705
+ _this10.onError();
706
+ _this10.removeClass(STATE_CLASS.ENTER);
707
+ return;
708
+ }
709
+ if (e.name === "NotAllowedError") {
710
+ _this10._errorTimer = util.setTimeout(_this10, function() {
711
+ _this10._errorTimer = null;
712
+ _this10.emit(AUTOPLAY_PREVENTED);
713
+ _this10.addClass(STATE_CLASS.NOT_ALLOW_AUTOPLAY);
714
+ _this10.removeClass(STATE_CLASS.ENTER);
715
+ _this10.pause();
716
+ _this10.setState(STATES.NOTALLOW);
717
+ }, 0);
718
+ }
719
+ });
720
+ } else {
721
+ XG_DEBUG.logWarn("video.play not return promise");
722
+ if (this.state < STATES.RUNNING) {
723
+ this.setState(STATES.RUNNING);
724
+ this.removeClass(STATE_CLASS.NOT_ALLOW_AUTOPLAY);
725
+ this.removeClass(STATE_CLASS.NO_START);
726
+ this.removeClass(STATE_CLASS.ENTER);
727
+ this.addClass(STATE_CLASS.PLAYING);
728
+ this.emit(AUTOPLAY_STARTED);
729
+ }
730
+ }
731
+ return playPromise;
732
+ }
733
+ }, {
734
+ key: "mediaPause",
735
+ value: function mediaPause() {
736
+ _get(_getPrototypeOf(Player2.prototype), "pause", this).call(this);
737
+ }
738
+ }, {
739
+ key: "videoPause",
740
+ value: function videoPause() {
741
+ _get(_getPrototypeOf(Player2.prototype), "pause", this).call(this);
742
+ }
743
+ }, {
744
+ key: "play",
745
+ value: function play() {
746
+ var _this11 = this;
747
+ this.removeClass(STATE_CLASS.PAUSED);
748
+ return runHooks(this, "play", function() {
749
+ return _this11.mediaPlay();
750
+ });
751
+ }
752
+ }, {
753
+ key: "pause",
754
+ value: function pause() {
755
+ var _this12 = this;
756
+ runHooks(this, "pause", function() {
757
+ _get(_getPrototypeOf(Player2.prototype), "pause", _this12).call(_this12);
758
+ });
759
+ }
760
+ }, {
761
+ key: "seek",
762
+ value: function seek(time, status) {
763
+ var _this13 = this;
764
+ if (!this.media || Number.isNaN(Number(time)) || !this.hasStart) {
765
+ return;
766
+ }
767
+ var _this$config4 = this.config, isSeekedPlay = _this$config4.isSeekedPlay, seekedStatus = _this$config4.seekedStatus;
768
+ var _status = status || (isSeekedPlay ? "play" : seekedStatus);
769
+ time = time < 0 ? 0 : time > this.duration ? parseInt(this.duration, 10) : time;
770
+ !this._isPauseBeforeSeek && (this._isPauseBeforeSeek = this.paused ? 2 : 1);
771
+ this._onceSeekCanplay && this.off(SEEKED, this._onceSeekCanplay);
772
+ this._onceSeekCanplay = function() {
773
+ _this13.removeClass(STATE_CLASS.ENTER);
774
+ _this13.isSeeking = false;
775
+ switch (_status) {
776
+ case "play":
777
+ _this13.play();
778
+ break;
779
+ case "pause":
780
+ _this13.pause();
781
+ break;
782
+ default:
783
+ _this13._isPauseBeforeSeek > 1 || _this13.paused ? _this13.pause() : _this13.play();
784
+ }
785
+ _this13._isPauseBeforeSeek = 0;
786
+ _this13._onceSeekCanplay = null;
787
+ };
788
+ this.once(SEEKED, this._onceSeekCanplay);
789
+ if (this.state < STATES.RUNNING) {
790
+ this.removeClass(STATE_CLASS.NO_START);
791
+ this.currentTime = time;
792
+ this.play();
793
+ } else {
794
+ this.currentTime = time;
795
+ }
796
+ }
797
+ }, {
798
+ key: "getInitDefinition",
799
+ value: function getInitDefinition() {
800
+ var _this14 = this;
801
+ var _this$config5 = this.config, definition = _this$config5.definition, url = _this$config5.url;
802
+ if (!url && definition && definition.list && definition.list.length > 0 && definition.defaultDefinition) {
803
+ definition.list.map(function(item) {
804
+ if (item.definition === definition.defaultDefinition) {
805
+ _this14.config.url = item.url;
806
+ _this14.curDefinition = item;
807
+ }
808
+ });
809
+ }
810
+ }
811
+ }, {
812
+ key: "changeDefinition",
813
+ value: function changeDefinition(to, from) {
814
+ var _this15 = this;
815
+ var definition = this.config.definition;
816
+ if (Array.isArray(definition === null || definition === void 0 ? void 0 : definition.list)) {
817
+ definition.list.forEach(function(item) {
818
+ if ((to === null || to === void 0 ? void 0 : to.definition) === item.definition) {
819
+ _this15.curDefinition = item;
820
+ }
821
+ });
822
+ }
823
+ if (to !== null && to !== void 0 && to.bitrate && typeof to.bitrate !== "number") {
824
+ to.bitrate = parseInt(to.bitrate, 10) || 0;
825
+ }
826
+ this.emit(DEFINITION_CHANGE, {
827
+ from,
828
+ to
829
+ });
830
+ if (!this.hasStart) {
831
+ this.config.url = to.url;
832
+ return;
833
+ }
834
+ var ret = this.switchURL(to.url, _objectSpread2({
835
+ seamless: definition.seamless !== false && typeof MediaSource !== "undefined" && typeof MediaSource.isTypeSupported === "function"
836
+ }, to));
837
+ if (ret && ret.then) {
838
+ ret.then(function() {
839
+ _this15.emit(AFTER_DEFINITION_CHANGE, {
840
+ from,
841
+ to
842
+ });
843
+ });
844
+ } else {
845
+ this.emit(AFTER_DEFINITION_CHANGE, {
846
+ from,
847
+ to
848
+ });
849
+ }
850
+ }
851
+ }, {
852
+ key: "reload",
853
+ value: function reload() {
854
+ this.load();
855
+ this.reloadFunc = function() {
856
+ this.play();
857
+ };
858
+ this.once(LOADED_DATA, this.reloadFunc);
859
+ }
860
+ }, {
861
+ key: "resetState",
862
+ value: function resetState() {
863
+ var _this16 = this;
864
+ var NOT_ALLOW_AUTOPLAY = STATE_CLASS.NOT_ALLOW_AUTOPLAY, PLAYING = STATE_CLASS.PLAYING, NO_START = STATE_CLASS.NO_START, PAUSED = STATE_CLASS.PAUSED, REPLAY2 = STATE_CLASS.REPLAY, ENTER = STATE_CLASS.ENTER, ENDED = STATE_CLASS.ENDED, ERROR2 = STATE_CLASS.ERROR, LOADING = STATE_CLASS.LOADING;
865
+ var clsList = [NOT_ALLOW_AUTOPLAY, PLAYING, NO_START, PAUSED, REPLAY2, ENTER, ENDED, ERROR2, LOADING];
866
+ this.hasStart = false;
867
+ this.isError = false;
868
+ this._useAutoplay = false;
869
+ this.mediaPause();
870
+ this._accPlayed.acc = 0;
871
+ this._accPlayed.t = 0;
872
+ this._accPlayed.loopAcc = 0;
873
+ clsList.forEach(function(cls) {
874
+ _this16.removeClass(cls);
875
+ });
876
+ this.addClass(STATE_CLASS.ENTER);
877
+ this.emit(RESET);
878
+ }
879
+ }, {
880
+ key: "reset",
881
+ value: function reset() {
882
+ var _this17 = this;
883
+ var unregisterPlugins = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
884
+ var isResetConfig = arguments.length > 1 ? arguments[1] : void 0;
885
+ this.resetState();
886
+ var plugins = this.plugins;
887
+ if (!plugins) {
888
+ return;
889
+ }
890
+ unregisterPlugins.map(function(pn) {
891
+ _this17.deregister(pn);
892
+ });
893
+ if (isResetConfig) {
894
+ var de = getDefaultConfig();
895
+ Object.keys(this.config).keys(function(k) {
896
+ if (_this17.config[k] !== "undefined" && (k === "plugins" || k === "presets" || k === "el" || k === "id")) {
897
+ _this17.config[k] = de[k];
898
+ }
899
+ });
900
+ }
901
+ }
902
+ }, {
903
+ key: "destroy",
904
+ value: function destroy() {
905
+ var _this18 = this;
906
+ var innerContainer = this.innerContainer, root = this.root, media = this.media;
907
+ if (!root || !media) {
908
+ return;
909
+ }
910
+ this.hasStart = false;
911
+ this._useAutoplay = false;
912
+ root.removeAttribute(PLATER_ID);
913
+ this.updateAcc("destroy");
914
+ this._unbindEvents();
915
+ this._detachSourceEvents(this.media);
916
+ util.clearAllTimers(this);
917
+ this.emit(DESTROY);
918
+ pluginsManager.destroy(this);
919
+ delHooksDescriptor(this);
920
+ _get(_getPrototypeOf(Player2.prototype), "destroy", this).call(this);
921
+ if (this.fullscreen && this._fullscreenEl === this.root) {
922
+ this.exitFullscreen();
923
+ }
924
+ if (innerContainer) {
925
+ var _c = innerContainer.children;
926
+ for (var i = 0; i < _c.length; i++) {
927
+ innerContainer.removeChild(_c[i]);
928
+ }
929
+ }
930
+ !innerContainer && media instanceof window.Node && root.contains(media) && root.removeChild(media);
931
+ ["topBar", "leftBar", "rightBar", "innerContainer"].map(function(item) {
932
+ _this18[item] && root.removeChild(_this18[item]);
933
+ _this18[item] = null;
934
+ });
935
+ var cList = root.className.split(" ");
936
+ if (cList.length > 0) {
937
+ root.className = cList.filter(function(name) {
938
+ return name.indexOf("xgplayer") < 0;
939
+ }).join(" ");
940
+ } else {
941
+ root.className = "";
942
+ }
943
+ this.removeAttribute("data-xgfill");
944
+ ["isSeeking", "isCanplay", "isActive", "cssfullscreen", "fullscreen"].forEach(function(key) {
945
+ _this18[key] = false;
946
+ });
947
+ }
948
+ }, {
949
+ key: "replay",
950
+ value: function replay() {
951
+ var _this19 = this;
952
+ this.removeClass(STATE_CLASS.ENDED);
953
+ this.currentTime = 0;
954
+ this.isSeeking = false;
955
+ runHooks(this, "replay", function() {
956
+ _this19.once(SEEKED, function() {
957
+ var playPromise = _this19.mediaPlay();
958
+ if (playPromise && playPromise.catch) {
959
+ playPromise.catch(function(err) {
960
+ console.log(err);
961
+ });
962
+ }
963
+ });
964
+ _this19.play();
965
+ _this19.emit(REPLAY);
966
+ _this19.onPlay();
967
+ });
968
+ }
969
+ }, {
970
+ key: "retry",
971
+ value: function retry() {
972
+ var _this20 = this;
973
+ this.removeClass(STATE_CLASS.ERROR);
974
+ this.addClass(STATE_CLASS.LOADING);
975
+ runHooks(this, "retry", function() {
976
+ var cur = _this20.currentTime;
977
+ var url = _this20.config.url;
978
+ var _srcRet = !util.isMSE(_this20.media) ? _this20.preProcessUrl(url) : {
979
+ url
980
+ };
981
+ _this20.src = _srcRet.url;
982
+ !_this20.config.isLive && (_this20.currentTime = cur);
983
+ _this20.once(CANPLAY, function() {
984
+ _this20.mediaPlay();
985
+ });
986
+ });
987
+ }
988
+ }, {
989
+ key: "changeFullStyle",
990
+ value: function changeFullStyle(root, el, rootClass, pClassName) {
991
+ if (!root) {
992
+ return;
993
+ }
994
+ if (!pClassName) {
995
+ pClassName = STATE_CLASS.PARENT_FULLSCREEN;
996
+ }
997
+ if (!this._orgCss) {
998
+ this._orgCss = util.filterStyleFromText(root);
999
+ }
1000
+ util.addClass(root, rootClass);
1001
+ if (el && el !== root && !this._orgPCss) {
1002
+ this._orgPCss = util.filterStyleFromText(el);
1003
+ util.addClass(el, pClassName);
1004
+ el.setAttribute(PLATER_ID, this.playerId);
1005
+ }
1006
+ }
1007
+ }, {
1008
+ key: "recoverFullStyle",
1009
+ value: function recoverFullStyle(root, el, rootClass, pClassName) {
1010
+ if (!pClassName) {
1011
+ pClassName = STATE_CLASS.PARENT_FULLSCREEN;
1012
+ }
1013
+ if (this._orgCss) {
1014
+ util.setStyleFromCsstext(root, this._orgCss);
1015
+ this._orgCss = "";
1016
+ }
1017
+ util.removeClass(root, rootClass);
1018
+ if (el && el !== root && this._orgPCss) {
1019
+ util.setStyleFromCsstext(el, this._orgPCss);
1020
+ this._orgPCss = "";
1021
+ util.removeClass(el, pClassName);
1022
+ el.removeAttribute(PLATER_ID);
1023
+ }
1024
+ }
1025
+ }, {
1026
+ key: "getFullscreen",
1027
+ value: function getFullscreen() {
1028
+ var el = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.config.fullscreenTarget;
1029
+ var root = this.root, media = this.media;
1030
+ if (!el) {
1031
+ el = root;
1032
+ }
1033
+ this._fullScreenOffset = {
1034
+ top: util.scrollTop(),
1035
+ left: util.scrollLeft()
1036
+ };
1037
+ this._fullscreenEl = el;
1038
+ this._fullActionFrom = "get";
1039
+ var fullEl = util.getFullScreenEl();
1040
+ if (fullEl === this._fullscreenEl) {
1041
+ this.onFullscreenChange();
1042
+ return Promise.resolve();
1043
+ }
1044
+ try {
1045
+ for (var i = 0; i < GET_FULLSCREEN_API.length; i++) {
1046
+ var key = GET_FULLSCREEN_API[i];
1047
+ if (el[key]) {
1048
+ var ret = key === "webkitRequestFullscreen" ? el.webkitRequestFullscreen(window.Element.ALLOW_KEYBOARD_INPUT) : el[key]();
1049
+ if (ret && ret.then) {
1050
+ return ret;
1051
+ } else {
1052
+ return Promise.resolve();
1053
+ }
1054
+ }
1055
+ }
1056
+ if (media.fullscreenEnabled || media.webkitSupportsFullscreen) {
1057
+ media.webkitEnterFullscreen();
1058
+ return Promise.resolve();
1059
+ }
1060
+ return Promise.reject(new Error("call getFullscreen fail"));
1061
+ } catch (err) {
1062
+ return Promise.reject(new Error("call getFullscreen fail"));
1063
+ }
1064
+ }
1065
+ }, {
1066
+ key: "exitFullscreen",
1067
+ value: function exitFullscreen(el) {
1068
+ if (this.isRotateFullscreen) {
1069
+ this.exitRotateFullscreen();
1070
+ }
1071
+ if (!this._fullscreenEl && !util.getFullScreenEl()) {
1072
+ return;
1073
+ }
1074
+ this.root;
1075
+ var media = this.media;
1076
+ this._fullActionFrom = "exit";
1077
+ try {
1078
+ for (var i = 0; i < EXIT_FULLSCREEN_API.length; i++) {
1079
+ var key = EXIT_FULLSCREEN_API[i];
1080
+ if (document[key]) {
1081
+ var ret = document[key]();
1082
+ if (ret && ret.then) {
1083
+ return ret;
1084
+ } else {
1085
+ return Promise.resolve();
1086
+ }
1087
+ }
1088
+ }
1089
+ if (media && media.webkitSupportsFullscreen) {
1090
+ media.webkitExitFullScreen();
1091
+ return Promise.resolve();
1092
+ }
1093
+ return Promise.reject(new Error("call exitFullscreen fail"));
1094
+ } catch (err) {
1095
+ return Promise.reject(new Error("call exitFullscreen fail"));
1096
+ }
1097
+ }
1098
+ }, {
1099
+ key: "getCssFullscreen",
1100
+ value: function getCssFullscreen() {
1101
+ var el = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.config.fullscreenTarget;
1102
+ if (this.isRotateFullscreen) {
1103
+ this.exitRotateFullscreen();
1104
+ } else if (this.fullscreen) {
1105
+ this.exitFullscreen();
1106
+ }
1107
+ var _class = el ? "".concat(STATE_CLASS.INNER_FULLSCREEN, " ").concat(STATE_CLASS.CSS_FULLSCREEN) : STATE_CLASS.CSS_FULLSCREEN;
1108
+ this.changeFullStyle(this.root, el, _class);
1109
+ var _this$config$fullscre = this.config.fullscreen, fullscreen = _this$config$fullscre === void 0 ? {} : _this$config$fullscre;
1110
+ var useCssFullscreen = fullscreen.useCssFullscreen === true || typeof fullscreen.useCssFullscreen === "function" && fullscreen.useCssFullscreen();
1111
+ if (useCssFullscreen) {
1112
+ this.fullscreen = true;
1113
+ this.emit(FULLSCREEN_CHANGE, true);
1114
+ }
1115
+ this._cssfullscreenEl = el;
1116
+ this.cssfullscreen = true;
1117
+ this.emit(CSS_FULLSCREEN_CHANGE, true);
1118
+ }
1119
+ }, {
1120
+ key: "exitCssFullscreen",
1121
+ value: function exitCssFullscreen() {
1122
+ var _class = this._cssfullscreenEl ? "".concat(STATE_CLASS.INNER_FULLSCREEN, " ").concat(STATE_CLASS.CSS_FULLSCREEN) : STATE_CLASS.CSS_FULLSCREEN;
1123
+ if (!this.fullscreen) {
1124
+ this.recoverFullStyle(this.root, this._cssfullscreenEl, _class);
1125
+ } else {
1126
+ var _this$config$fullscre2 = this.config.fullscreen, fullscreen = _this$config$fullscre2 === void 0 ? {} : _this$config$fullscre2;
1127
+ var useCssFullscreen = fullscreen.useCssFullscreen === true || typeof fullscreen.useCssFullscreen === "function" && fullscreen.useCssFullscreen();
1128
+ if (useCssFullscreen) {
1129
+ this.recoverFullStyle(this.root, this._cssfullscreenEl, _class);
1130
+ this.fullscreen = false;
1131
+ this.emit(FULLSCREEN_CHANGE, false);
1132
+ } else {
1133
+ this.removeClass(_class);
1134
+ }
1135
+ }
1136
+ this._cssfullscreenEl = null;
1137
+ this.cssfullscreen = false;
1138
+ this.emit(CSS_FULLSCREEN_CHANGE, false);
1139
+ }
1140
+ }, {
1141
+ key: "getRotateFullscreen",
1142
+ value: function getRotateFullscreen() {
1143
+ var el = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.config.fullscreenTarget;
1144
+ if (this.cssfullscreen) {
1145
+ this.exitCssFullscreen(el);
1146
+ }
1147
+ var _class = el ? "".concat(STATE_CLASS.INNER_FULLSCREEN, " ").concat(STATE_CLASS.ROTATE_FULLSCREEN) : STATE_CLASS.ROTATE_FULLSCREEN;
1148
+ this._fullscreenEl = el || this.root;
1149
+ this.changeFullStyle(this.root, el, _class, STATE_CLASS.PARENT_ROTATE_FULLSCREEN);
1150
+ this.isRotateFullscreen = true;
1151
+ this.fullscreen = true;
1152
+ this.setRotateDeg(90);
1153
+ this._rootStyle = this.root.getAttribute("style");
1154
+ this.root.style.width = "".concat(window.innerHeight, "px");
1155
+ this.emit(FULLSCREEN_CHANGE, true);
1156
+ }
1157
+ }, {
1158
+ key: "exitRotateFullscreen",
1159
+ value: function exitRotateFullscreen(el) {
1160
+ var _class = this._fullscreenEl !== this.root ? "".concat(STATE_CLASS.INNER_FULLSCREEN, " ").concat(STATE_CLASS.ROTATE_FULLSCREEN) : STATE_CLASS.ROTATE_FULLSCREEN;
1161
+ this.recoverFullStyle(this.root, this._fullscreenEl, _class, STATE_CLASS.PARENT_ROTATE_FULLSCREEN);
1162
+ this.isRotateFullscreen = false;
1163
+ this.fullscreen = false;
1164
+ this.setRotateDeg(0);
1165
+ this.emit(FULLSCREEN_CHANGE, false);
1166
+ if (this._rootStyle) {
1167
+ this.root.style.style = this._rootStyle;
1168
+ this._rootStyle = false;
1169
+ }
1170
+ }
1171
+ }, {
1172
+ key: "setRotateDeg",
1173
+ value: function setRotateDeg(deg) {
1174
+ if (window.orientation === 90 || window.orientation === -90) {
1175
+ this.rotateDeg = 0;
1176
+ } else {
1177
+ this.rotateDeg = deg;
1178
+ }
1179
+ }
1180
+ }, {
1181
+ key: "focus",
1182
+ value: function focus() {
1183
+ var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1184
+ autoHide: !this.config.closeDelayBlur,
1185
+ delay: this.config.inactive
1186
+ };
1187
+ if (this.isActive) {
1188
+ this.onFocus(data);
1189
+ return;
1190
+ }
1191
+ this.emit(PLAYER_FOCUS, _objectSpread2({
1192
+ paused: this.paused,
1193
+ ended: this.ended
1194
+ }, data));
1195
+ }
1196
+ }, {
1197
+ key: "blur",
1198
+ value: function blur() {
1199
+ var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1200
+ ignorePaused: false
1201
+ };
1202
+ if (!this.isActive) {
1203
+ this.onBlur(data);
1204
+ return;
1205
+ }
1206
+ this.emit(PLAYER_BLUR, _objectSpread2({
1207
+ paused: this.paused,
1208
+ ended: this.ended
1209
+ }, data));
1210
+ }
1211
+ }, {
1212
+ key: "onFocus",
1213
+ value: function onFocus() {
1214
+ var _this21 = this;
1215
+ var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1216
+ autoHide: true,
1217
+ delay: 3e3
1218
+ };
1219
+ var innerStates = this.innerStates;
1220
+ this.isActive = true;
1221
+ this.removeClass(STATE_CLASS.INACTIVE);
1222
+ if (this.userTimer) {
1223
+ util.clearTimeout(this, this.userTimer);
1224
+ this.userTimer = null;
1225
+ }
1226
+ if (data.isLock !== void 0) {
1227
+ innerStates.isActiveLocked = data.isLock;
1228
+ }
1229
+ if (data.autoHide === false || data.isLock === true || innerStates.isActiveLocked) {
1230
+ if (this.userTimer) {
1231
+ util.clearTimeout(this, this.userTimer);
1232
+ this.userTimer = null;
1233
+ }
1234
+ return;
1235
+ }
1236
+ var time = data && data.delay ? data.delay : this.config.inactive;
1237
+ this.userTimer = util.setTimeout(this, function() {
1238
+ _this21.userTimer = null;
1239
+ _this21.blur();
1240
+ }, time);
1241
+ }
1242
+ }, {
1243
+ key: "onBlur",
1244
+ value: function onBlur() {
1245
+ var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$ignorePaused = _ref.ignorePaused, ignorePaused = _ref$ignorePaused === void 0 ? false : _ref$ignorePaused;
1246
+ if (!this.isActive || this.innerStates.isActiveLocked) {
1247
+ return;
1248
+ }
1249
+ var closePauseVideoFocus = this.config.closePauseVideoFocus;
1250
+ this.isActive = false;
1251
+ if (ignorePaused || closePauseVideoFocus || !this.paused && !this.ended) {
1252
+ this.addClass(STATE_CLASS.INACTIVE);
1253
+ }
1254
+ }
1255
+ }, {
1256
+ key: "onEmptied",
1257
+ value: function onEmptied() {
1258
+ this.updateAcc("emptied");
1259
+ }
1260
+ }, {
1261
+ key: "onCanplay",
1262
+ value: function onCanplay() {
1263
+ this.removeClass(STATE_CLASS.ENTER);
1264
+ this.removeClass(STATE_CLASS.ERROR);
1265
+ this.removeClass(STATE_CLASS.LOADING);
1266
+ this.isCanplay = true;
1267
+ this.waitTimer && util.clearTimeout(this, this.waitTimer);
1268
+ }
1269
+ }, {
1270
+ key: "onLoadeddata",
1271
+ value: function onLoadeddata() {
1272
+ this.isError = false;
1273
+ this.isSeeking = false;
1274
+ }
1275
+ }, {
1276
+ key: "onLoadstart",
1277
+ value: function onLoadstart() {
1278
+ this.removeClass(STATE_CLASS.ERROR);
1279
+ this.isCanplay = false;
1280
+ }
1281
+ }, {
1282
+ key: "onPlay",
1283
+ value: function onPlay() {
1284
+ if (this.state === STATES.ENDED) {
1285
+ this.setState(STATES.RUNNING);
1286
+ }
1287
+ this.removeClass(STATE_CLASS.PAUSED);
1288
+ this.ended && this.removeClass(STATE_CLASS.ENDED);
1289
+ !this.config.closePlayVideoFocus && this.focus();
1290
+ }
1291
+ }, {
1292
+ key: "onPause",
1293
+ value: function onPause() {
1294
+ this.addClass(STATE_CLASS.PAUSED);
1295
+ this.updateAcc("pause");
1296
+ if (!this.config.closePauseVideoFocus) {
1297
+ if (this.userTimer) {
1298
+ util.clearTimeout(this, this.userTimer);
1299
+ this.userTimer = null;
1300
+ }
1301
+ this.focus();
1302
+ }
1303
+ }
1304
+ }, {
1305
+ key: "onEnded",
1306
+ value: function onEnded() {
1307
+ this.updateAcc("ended");
1308
+ this.addClass(STATE_CLASS.ENDED);
1309
+ this.setState(STATES.ENDED);
1310
+ }
1311
+ }, {
1312
+ key: "onError",
1313
+ value: function onError() {
1314
+ this.isError = true;
1315
+ this.updateAcc("error");
1316
+ this.removeClass(STATE_CLASS.NOT_ALLOW_AUTOPLAY);
1317
+ this.removeClass(STATE_CLASS.NO_START);
1318
+ this.removeClass(STATE_CLASS.ENTER);
1319
+ this.removeClass(STATE_CLASS.LOADING);
1320
+ this.addClass(STATE_CLASS.ERROR);
1321
+ }
1322
+ }, {
1323
+ key: "onSeeking",
1324
+ value: function onSeeking() {
1325
+ if (!this.isSeeking) {
1326
+ this.updateAcc("seeking");
1327
+ }
1328
+ this.isSeeking = true;
1329
+ this.addClass(STATE_CLASS.SEEKING);
1330
+ }
1331
+ }, {
1332
+ key: "onSeeked",
1333
+ value: function onSeeked() {
1334
+ this.isSeeking = false;
1335
+ if (this.waitTimer) {
1336
+ util.clearTimeout(this, this.waitTimer);
1337
+ }
1338
+ this.removeClass(STATE_CLASS.LOADING);
1339
+ this.removeClass(STATE_CLASS.SEEKING);
1340
+ }
1341
+ }, {
1342
+ key: "onWaiting",
1343
+ value: function onWaiting() {
1344
+ var _this22 = this;
1345
+ if (this.waitTimer) {
1346
+ util.clearTimeout(this, this.waitTimer);
1347
+ }
1348
+ this.updateAcc("waiting");
1349
+ this.waitTimer = util.setTimeout(this, function() {
1350
+ _this22.addClass(STATE_CLASS.LOADING);
1351
+ util.clearTimeout(_this22, _this22.waitTimer);
1352
+ _this22.waitTimer = null;
1353
+ }, this.config.minWaitDelay);
1354
+ }
1355
+ }, {
1356
+ key: "onPlaying",
1357
+ value: function onPlaying() {
1358
+ var _this23 = this;
1359
+ this.isError = false;
1360
+ var NO_START = STATE_CLASS.NO_START, PAUSED = STATE_CLASS.PAUSED, ENDED = STATE_CLASS.ENDED, ERROR2 = STATE_CLASS.ERROR, REPLAY2 = STATE_CLASS.REPLAY, LOADING = STATE_CLASS.LOADING;
1361
+ var clsList = [NO_START, PAUSED, ENDED, ERROR2, REPLAY2, LOADING];
1362
+ clsList.forEach(function(cls) {
1363
+ _this23.removeClass(cls);
1364
+ });
1365
+ }
1366
+ }, {
1367
+ key: "onTimeupdate",
1368
+ value: function onTimeupdate() {
1369
+ !this._videoHeight && this.media.videoHeight && this.resize();
1370
+ if ((this.waitTimer || this.hasClass(STATE_CLASS.LOADING)) && this.media.readyState > 2) {
1371
+ this.removeClass(STATE_CLASS.LOADING);
1372
+ util.clearTimeout(this, this.waitTimer);
1373
+ this.waitTimer = null;
1374
+ }
1375
+ if (!this.paused && this.state < STATES.RUNNING && this.duration) {
1376
+ this.setState(STATES.RUNNING);
1377
+ this.emit(AUTOPLAY_STARTED);
1378
+ }
1379
+ if (!this._accPlayed.t && !this.paused && !this.ended) {
1380
+ this._accPlayed.t = new Date().getTime();
1381
+ }
1382
+ }
1383
+ }, {
1384
+ key: "onVolumechange",
1385
+ value: function onVolumechange() {
1386
+ util.typeOf(this.config.volume) === "Number" && (this.config.volume = this.volume);
1387
+ }
1388
+ }, {
1389
+ key: "onRatechange",
1390
+ value: function onRatechange() {
1391
+ this.config.defaultPlaybackRate = this.playbackRate;
1392
+ }
1393
+ }, {
1394
+ key: "emitUserAction",
1395
+ value: function emitUserAction(event, action, params) {
1396
+ if (!this.media || !action || !event) {
1397
+ return;
1398
+ }
1399
+ var eventType = util.typeOf(event) === "String" ? event : event.type || "";
1400
+ if (params.props && util.typeOf(params.props) !== "Array") {
1401
+ params.props = [params.props];
1402
+ }
1403
+ this.emit(USER_ACTION, _objectSpread2({
1404
+ eventType,
1405
+ action,
1406
+ currentTime: this.currentTime,
1407
+ duration: this.duration,
1408
+ ended: this.ended,
1409
+ event
1410
+ }, params));
1411
+ }
1412
+ }, {
1413
+ key: "updateAcc",
1414
+ value: function updateAcc(endType) {
1415
+ if (this._accPlayed.t) {
1416
+ var _at = new Date().getTime() - this._accPlayed.t;
1417
+ this._accPlayed.acc += _at;
1418
+ this._accPlayed.t = 0;
1419
+ if (endType === "ended" || this.ended) {
1420
+ this._accPlayed.loopAcc = this._accPlayed.acc;
1421
+ }
1422
+ }
1423
+ }
1424
+ }, {
1425
+ key: "checkBuffer",
1426
+ value: function checkBuffer(time) {
1427
+ var buffered = this.media.buffered;
1428
+ if (!buffered || buffered.length === 0 || !this.duration) {
1429
+ return true;
1430
+ }
1431
+ var currentTime = time || this.media.currentTime || 0.2;
1432
+ var len = buffered.length;
1433
+ for (var i = 0; i < len; i++) {
1434
+ if (buffered.start(i) <= currentTime && buffered.end(i) > currentTime) {
1435
+ return true;
1436
+ }
1437
+ }
1438
+ return false;
1439
+ }
1440
+ }, {
1441
+ key: "resizePosition",
1442
+ value: function resizePosition() {
1443
+ var _this$videoPos = this.videoPos, rotate = _this$videoPos.rotate, vy = _this$videoPos.vy, vx = _this$videoPos.vx, h = _this$videoPos.h, w = _this$videoPos.w;
1444
+ if (rotate < 0 && !vy && !vx) {
1445
+ return;
1446
+ }
1447
+ var _pi = this.videoPos._pi;
1448
+ if (!_pi && this.media.videoHeight) {
1449
+ _pi = this.media.videoWidth / this.media.videoHeight * 100;
1450
+ }
1451
+ if (!_pi) {
1452
+ return;
1453
+ }
1454
+ this.videoPos.pi = _pi;
1455
+ var _pos = {
1456
+ rotate
1457
+ };
1458
+ var offsetY = 0;
1459
+ var offsetX = 0;
1460
+ var scale = 1;
1461
+ var _t = Math.abs(rotate / 90);
1462
+ var root = this.root, innerContainer = this.innerContainer;
1463
+ var width = root.offsetWidth;
1464
+ var height = innerContainer ? innerContainer.offsetHeight : root.offsetHeight;
1465
+ var rHeight = height;
1466
+ var rWidth = width;
1467
+ if (_t % 2 === 0) {
1468
+ scale = h > 0 ? 100 / h : w > 0 ? 100 / w : 1;
1469
+ _pos.scale = scale;
1470
+ offsetY = vy > 0 ? (100 - h) / 2 - vy : 0;
1471
+ _pos.y = _t === 2 ? 0 - offsetY : offsetY;
1472
+ offsetX = vx > 0 ? (100 - w) / 2 - vx : 0;
1473
+ _pos.x = _t === 2 ? 0 - offsetX : offsetX;
1474
+ this.media.style.width = "".concat(rWidth, "px");
1475
+ this.media.style.height = "".concat(rHeight, "px");
1476
+ } else if (_t % 2 === 1) {
1477
+ rWidth = height;
1478
+ rHeight = width;
1479
+ var offset = height - width;
1480
+ offsetX = -offset / 2 / rWidth * 100;
1481
+ _pos.x = _t === 3 ? offsetX + vy / 2 : offsetX - vy / 2;
1482
+ offsetY = offset / 2 / rHeight * 100;
1483
+ _pos.y = _t === 3 ? offsetY + vx / 2 : offsetY - vx / 2;
1484
+ _pos.scale = scale;
1485
+ this.media.style.width = "".concat(rWidth, "px");
1486
+ this.media.style.height = "".concat(rHeight, "px");
1487
+ }
1488
+ var formStyle = util.getTransformStyle(_pos, this.media.style.transform || this.media.style.webkitTransform);
1489
+ this.media.style.transform = formStyle;
1490
+ this.media.style.webkitTransform = formStyle;
1491
+ }
1492
+ }, {
1493
+ key: "position",
1494
+ value: function position() {
1495
+ var pos = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1496
+ h: 0,
1497
+ y: 0,
1498
+ x: 0,
1499
+ w: 0
1500
+ };
1501
+ if (!this.media || !pos || !pos.h) {
1502
+ return;
1503
+ }
1504
+ var videoPos = this.videoPos;
1505
+ videoPos.h = pos.h * 100 || 0;
1506
+ videoPos.w = pos.w * 100 || 0;
1507
+ videoPos.vx = pos.x * 100 || 0;
1508
+ videoPos.vy = pos.y * 100 || 0;
1509
+ this.resizePosition();
1510
+ }
1511
+ }, {
1512
+ key: "setConfig",
1513
+ value: function setConfig(config) {
1514
+ var _this24 = this;
1515
+ if (!config) {
1516
+ return;
1517
+ }
1518
+ Object.keys(config).map(function(key) {
1519
+ if (key !== "plugins") {
1520
+ _this24.config[key] = config[key];
1521
+ var plugin = _this24.plugins[key.toLowerCase()];
1522
+ if (plugin && util.typeOf(plugin.setConfig) === "Function") {
1523
+ plugin.setConfig(config[key]);
1524
+ }
1525
+ }
1526
+ });
1527
+ }
1528
+ }, {
1529
+ key: "playNext",
1530
+ value: function playNext(config) {
1531
+ var _this25 = this;
1532
+ this.resetState();
1533
+ this.setConfig(config);
1534
+ this._currentTime = 0;
1535
+ this._duration = 0;
1536
+ runHooks(this, "playnext", function() {
1537
+ _this25.start();
1538
+ _this25.emit(PLAYNEXT, config);
1539
+ });
1540
+ }
1541
+ }, {
1542
+ key: "resize",
1543
+ value: function resize() {
1544
+ var _this26 = this;
1545
+ if (!this.media) {
1546
+ return;
1547
+ }
1548
+ var containerSize = this.root.getBoundingClientRect();
1549
+ this.sizeInfo.width = containerSize.width;
1550
+ this.sizeInfo.height = containerSize.height;
1551
+ this.sizeInfo.left = containerSize.left;
1552
+ this.sizeInfo.top = containerSize.top;
1553
+ var _this$media = this.media, videoWidth = _this$media.videoWidth, videoHeight = _this$media.videoHeight;
1554
+ var _this$config6 = this.config, fitVideoSize = _this$config6.fitVideoSize, videoFillMode = _this$config6.videoFillMode;
1555
+ if (videoFillMode === "fill" || videoFillMode === "cover" || videoFillMode === "contain") {
1556
+ this.setAttribute("data-xgfill", videoFillMode);
1557
+ }
1558
+ if (!videoHeight || !videoWidth) {
1559
+ return;
1560
+ }
1561
+ this._videoHeight = videoHeight;
1562
+ this._videoWidth = videoWidth;
1563
+ var controlsHeight = this.controls && this.innerContainer ? this.controls.root.getBoundingClientRect().height : 0;
1564
+ var width = containerSize.width;
1565
+ var height = containerSize.height - controlsHeight;
1566
+ var videoFit = parseInt(videoWidth / videoHeight * 1e3, 10);
1567
+ var fit = parseInt(width / height * 1e3, 10);
1568
+ var rWidth = width;
1569
+ var rHeight = height;
1570
+ var _style = {};
1571
+ if (fitVideoSize === "auto" && fit > videoFit || fitVideoSize === "fixWidth") {
1572
+ rHeight = width / videoFit * 1e3;
1573
+ if (this.config.fluid) {
1574
+ _style.paddingTop = "".concat(rHeight * 100 / rWidth, "%");
1575
+ } else {
1576
+ _style.height = "".concat(rHeight + controlsHeight, "px");
1577
+ }
1578
+ } else if (fitVideoSize === "auto" && fit < videoFit || fitVideoSize === "fixHeight") {
1579
+ rWidth = videoFit * height / 1e3;
1580
+ _style.width = "".concat(rWidth, "px");
1581
+ }
1582
+ if (!this.fullscreen && !this.cssfullscreen) {
1583
+ Object.keys(_style).forEach(function(key) {
1584
+ _this26.root.style[key] = _style[key];
1585
+ });
1586
+ }
1587
+ if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
1588
+ this.setAttribute("data-xgfill", "cover");
1589
+ }
1590
+ var data = {
1591
+ videoScale: videoFit,
1592
+ vWidth: rWidth,
1593
+ vHeight: rHeight,
1594
+ cWidth: rWidth,
1595
+ cHeight: rHeight + controlsHeight
1596
+ };
1597
+ this.resizePosition();
1598
+ this.emit(VIDEO_RESIZE, data);
1599
+ }
1600
+ }, {
1601
+ key: "updateObjectPosition",
1602
+ value: function updateObjectPosition() {
1603
+ var left = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
1604
+ var top = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
1605
+ if (this.media.updateObjectPosition) {
1606
+ this.media.updateObjectPosition(left, top);
1607
+ return;
1608
+ }
1609
+ this.media.style.objectPosition = "".concat(left * 100, "% ").concat(top * 100, "%");
1610
+ }
1611
+ }, {
1612
+ key: "setState",
1613
+ value: function setState(newState) {
1614
+ XG_DEBUG.logInfo("setState", "state from:".concat(STATE_ARRAY[this.state], " to:").concat(STATE_ARRAY[newState]));
1615
+ this._state = newState;
1616
+ }
1617
+ }, {
1618
+ key: "preProcessUrl",
1619
+ value: function preProcessUrl(url, ext) {
1620
+ var preProcessUrl2 = this.config.preProcessUrl;
1621
+ return !util.isBlob(url) && preProcessUrl2 && typeof preProcessUrl2 === "function" ? preProcessUrl2(url, ext) : {
1622
+ url
1623
+ };
1624
+ }
1625
+ }, {
1626
+ key: "state",
1627
+ get: function get() {
1628
+ return this._state;
1629
+ }
1630
+ }, {
1631
+ key: "isFullscreen",
1632
+ get: function get() {
1633
+ return this.fullscreen;
1634
+ }
1635
+ }, {
1636
+ key: "isCssfullScreen",
1637
+ get: function get() {
1638
+ return this.cssfullscreen;
1639
+ }
1640
+ }, {
1641
+ key: "hasStart",
1642
+ get: function get() {
1643
+ return this._hasStart;
1644
+ },
1645
+ set: function set(bool) {
1646
+ if (typeof bool === "boolean") {
1647
+ this._hasStart = bool;
1648
+ if (bool === false) {
1649
+ this.setState(STATES.READY);
1650
+ }
1651
+ this.emit("hasstart");
1652
+ }
1653
+ }
1654
+ }, {
1655
+ key: "isPlaying",
1656
+ get: function get() {
1657
+ return this._state === STATES.RUNNING || this._state === STATES.ENDED;
1658
+ },
1659
+ set: function set(value) {
1660
+ if (value) {
1661
+ this.setState(STATES.RUNNING);
1662
+ } else {
1663
+ this._state >= STATES.RUNNING && this.setState(STATES.ATTACHED);
1664
+ }
1665
+ }
1666
+ }, {
1667
+ key: "definitionList",
1668
+ get: function get() {
1669
+ if (!this.config || !this.config.definition) {
1670
+ return [];
1671
+ }
1672
+ return this.config.definition.list || [];
1673
+ },
1674
+ set: function set(list) {
1675
+ var _this27 = this;
1676
+ var definition = this.config.definition;
1677
+ var curDef = null;
1678
+ var targetDef = null;
1679
+ definition.list = list;
1680
+ this.emit("resourceReady", list);
1681
+ list.forEach(function(item) {
1682
+ var _this27$curDefinition;
1683
+ if (((_this27$curDefinition = _this27.curDefinition) === null || _this27$curDefinition === void 0 ? void 0 : _this27$curDefinition.definition) === item.definition) {
1684
+ curDef = item;
1685
+ }
1686
+ if (definition.defaultDefinition === item.definition) {
1687
+ targetDef = item;
1688
+ }
1689
+ });
1690
+ if (!targetDef && list.length > 0) {
1691
+ targetDef = list[0];
1692
+ }
1693
+ curDef ? this.changeDefinition(curDef) : targetDef && this.changeDefinition(targetDef);
1694
+ }
1695
+ }, {
1696
+ key: "videoFrameInfo",
1697
+ get: function get() {
1698
+ var ret = {
1699
+ total: 0,
1700
+ dropped: 0,
1701
+ corrupted: 0,
1702
+ droppedRate: 0,
1703
+ droppedDuration: 0
1704
+ };
1705
+ if (!this.media || !this.media.getVideoPlaybackQuality) {
1706
+ return ret;
1707
+ }
1708
+ var _quality = this.media.getVideoPlaybackQuality();
1709
+ ret.dropped = _quality.droppedVideoFrames || 0;
1710
+ ret.total = _quality.totalVideoFrames || 0;
1711
+ ret.corrupted = _quality.corruptedVideoFrames || 0;
1712
+ if (ret.total > 0) {
1713
+ ret.droppedRate = ret.dropped / ret.total * 100;
1714
+ ret.droppedDuration = parseInt(this.cumulateTime / ret.total * ret.dropped, 0);
1715
+ }
1716
+ return ret;
1717
+ }
1718
+ }, {
1719
+ key: "lang",
1720
+ get: function get() {
1721
+ return this.config.lang;
1722
+ },
1723
+ set: function set(lang) {
1724
+ var result = I18N.langKeys.filter(function(key) {
1725
+ return key === lang;
1726
+ });
1727
+ if (result.length === 0 && lang !== "zh") {
1728
+ console.error("Sorry, set lang fail, because the language [".concat(lang, "] is not supported now, list of all supported languages is [").concat(I18N.langKeys.join(), "] "));
1729
+ return;
1730
+ }
1731
+ this.config.lang = lang;
1732
+ pluginsManager.setLang(lang, this);
1733
+ }
1734
+ }, {
1735
+ key: "i18n",
1736
+ get: function get() {
1737
+ var _l = this.config.lang;
1738
+ if (_l === "zh") {
1739
+ _l = "zh-cn";
1740
+ }
1741
+ return this.__i18n.lang[_l] || this.__i18n.lang.en;
1742
+ }
1743
+ }, {
1744
+ key: "i18nKeys",
1745
+ get: function get() {
1746
+ return this.__i18n.textKeys || {};
1747
+ }
1748
+ }, {
1749
+ key: "version",
1750
+ get: function get() {
1751
+ return version;
1752
+ }
1753
+ }, {
1754
+ key: "playerId",
1755
+ get: function get() {
1756
+ return this._pluginInfoId;
1757
+ }
1758
+ }, {
1759
+ key: "url",
1760
+ get: function get() {
1761
+ return this.__url || this.config.url;
1762
+ },
1763
+ set: function set(url) {
1764
+ this.__url = url;
1765
+ }
1766
+ }, {
1767
+ key: "poster",
1768
+ get: function get() {
1769
+ return this.plugins.poster ? this.plugins.poster.config.poster : this.config.poster;
1770
+ },
1771
+ set: function set(posterUrl) {
1772
+ this.plugins.poster && this.plugins.poster.update(posterUrl);
1773
+ }
1774
+ }, {
1775
+ key: "readyState",
1776
+ get: function get() {
1777
+ return _get(_getPrototypeOf(Player2.prototype), "readyState", this);
1778
+ }
1779
+ }, {
1780
+ key: "error",
1781
+ get: function get() {
1782
+ var key = _get(_getPrototypeOf(Player2.prototype), "error", this);
1783
+ return this.i18n[key] || key;
1784
+ }
1785
+ }, {
1786
+ key: "networkState",
1787
+ get: function get() {
1788
+ return _get(_getPrototypeOf(Player2.prototype), "networkState", this);
1789
+ }
1790
+ }, {
1791
+ key: "fullscreenChanging",
1792
+ get: function get() {
1793
+ return !(this._fullScreenOffset === null);
1794
+ }
1795
+ }, {
1796
+ key: "cumulateTime",
1797
+ get: function get() {
1798
+ var _this$_accPlayed = this._accPlayed, acc = _this$_accPlayed.acc, t = _this$_accPlayed.t;
1799
+ return t ? new Date().getTime() - t + acc : acc;
1800
+ }
1801
+ }, {
1802
+ key: "zoom",
1803
+ get: function get() {
1804
+ return this.config.zoom;
1805
+ },
1806
+ set: function set(value) {
1807
+ this.config.zoom = value;
1808
+ }
1809
+ }, {
1810
+ key: "videoRotateDeg",
1811
+ get: function get() {
1812
+ return this.videoPos.rotate;
1813
+ },
1814
+ set: function set(val) {
1815
+ val = util.convertDeg(val);
1816
+ if (val % 90 !== 0 || val === this.videoPos.rotate) {
1817
+ return;
1818
+ }
1819
+ this.videoPos.rotate = val;
1820
+ this.resizePosition();
1821
+ }
1822
+ }, {
1823
+ key: "avgSpeed",
1824
+ get: function get() {
1825
+ return AVG_SPEED;
1826
+ },
1827
+ set: function set(val) {
1828
+ AVG_SPEED = val;
1829
+ }
1830
+ }, {
1831
+ key: "realTimeSpeed",
1832
+ get: function get() {
1833
+ return REAL_TIME_SPEED;
1834
+ },
1835
+ set: function set(val) {
1836
+ REAL_TIME_SPEED = val;
1837
+ }
1838
+ }, {
1839
+ key: "offsetCurrentTime",
1840
+ get: function get() {
1841
+ return this._offsetInfo.currentTime || 0;
1842
+ },
1843
+ set: function set(val) {
1844
+ this._offsetInfo.currentTime = val;
1845
+ }
1846
+ }, {
1847
+ key: "offsetDuration",
1848
+ get: function get() {
1849
+ return this._offsetInfo.duration || 0;
1850
+ },
1851
+ set: function set(val) {
1852
+ this._offsetInfo.duration = val || 0;
1853
+ }
1854
+ }, {
1855
+ key: "hook",
1856
+ value: function hook$1(hookName, handler) {
1857
+ return hook.call.apply(hook, [this].concat(Array.prototype.slice.call(arguments)));
1858
+ }
1859
+ }, {
1860
+ key: "useHooks",
1861
+ value: function useHooks$1(hookName, handler) {
1862
+ return useHooks.call.apply(useHooks, [this].concat(Array.prototype.slice.call(arguments)));
1863
+ }
1864
+ }, {
1865
+ key: "removeHooks",
1866
+ value: function removeHooks$1(hookName, handler) {
1867
+ return removeHooks.call.apply(removeHooks, [this].concat(Array.prototype.slice.call(arguments)));
1868
+ }
1869
+ }, {
1870
+ key: "usePluginHooks",
1871
+ value: function usePluginHooks$1(pluginName, hookName, handler) {
1872
+ for (var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
1873
+ args[_key - 3] = arguments[_key];
1874
+ }
1875
+ return usePluginHooks.call.apply(usePluginHooks, [this].concat(Array.prototype.slice.call(arguments)));
1876
+ }
1877
+ }, {
1878
+ key: "removePluginHooks",
1879
+ value: function removePluginHooks$1(pluginName, hookName, handler) {
1880
+ for (var _len2 = arguments.length, args = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
1881
+ args[_key2 - 3] = arguments[_key2];
1882
+ }
1883
+ return removePluginHooks.call.apply(removePluginHooks, [this].concat(Array.prototype.slice.call(arguments)));
1884
+ }
1885
+ }, {
1886
+ key: "setUserActive",
1887
+ value: function setUserActive(isActive, isMuted) {
1888
+ if (typeof isMuted === "boolean" && isMuted !== this.muted) {
1889
+ this.addInnerOP("volumechange");
1890
+ this.muted = isMuted;
1891
+ }
1892
+ pluginsManager.setCurrentUserActive(this.playerId, isActive);
1893
+ }
1894
+ }], [{
1895
+ key: "debugger",
1896
+ get: function get() {
1897
+ return XG_DEBUG.config.debug;
1898
+ },
1899
+ set: function set(value) {
1900
+ XG_DEBUG.config.debug = value;
1901
+ }
1902
+ }, {
1903
+ key: "getCurrentUserActivePlayerId",
1904
+ value: function getCurrentUserActivePlayerId() {
1905
+ return pluginsManager.getCurrentUseActiveId();
1906
+ }
1907
+ }, {
1908
+ key: "setCurrentUserActive",
1909
+ value: function setCurrentUserActive(playerId, isActive) {
1910
+ pluginsManager.setCurrentUserActive(playerId, isActive);
1911
+ }
1912
+ }, {
1913
+ key: "isHevcSupported",
1914
+ value: function isHevcSupported() {
1915
+ return sniffer.isHevcSupported();
1916
+ }
1917
+ }, {
1918
+ key: "probeConfigSupported",
1919
+ value: function probeConfigSupported(info) {
1920
+ return sniffer.probeConfigSupported(info);
1921
+ }
1922
+ }, {
1923
+ key: "install",
1924
+ value: function install(name, descriptor) {
1925
+ if (!Player2.plugins) {
1926
+ Player2.plugins = {};
1927
+ }
1928
+ if (!Player2.plugins[name]) {
1929
+ Player2.plugins[name] = descriptor;
1930
+ }
1931
+ }
1932
+ }, {
1933
+ key: "use",
1934
+ value: function use(name, descriptor) {
1935
+ if (!Player2.plugins) {
1936
+ Player2.plugins = {};
1937
+ }
1938
+ Player2.plugins[name] = descriptor;
1939
+ }
1940
+ }]);
1941
+ return Player2;
1942
+ }(MediaProxy);
1943
+ _defineProperty(Player, "defaultPreset", null);
1944
+ _defineProperty(Player, "XgVideoProxy", null);
1945
+ export { Player as default };