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,827 @@
1
+ import { typeof as _typeof, toConsumableArray as _toConsumableArray } from "../_virtual/_rollupPluginBabelHelpers.js";
2
+ import XG_DEBUG from "./debug.js";
3
+ import XgplayerTimeRange from "./xgplayerTimeRange.js";
4
+ var util = {};
5
+ util.createDom = function() {
6
+ var el = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "div";
7
+ var tpl = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
8
+ var attrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
9
+ var cname = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
10
+ var dom = document.createElement(el);
11
+ dom.className = cname;
12
+ dom.innerHTML = tpl;
13
+ Object.keys(attrs).forEach(function(item) {
14
+ var key = item;
15
+ var value = attrs[item];
16
+ if (el === "video" || el === "audio" || el === "live-video") {
17
+ if (value) {
18
+ dom.setAttribute(key, value);
19
+ }
20
+ } else {
21
+ dom.setAttribute(key, value);
22
+ }
23
+ });
24
+ return dom;
25
+ };
26
+ util.createDomFromHtml = function(html) {
27
+ var attrs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
28
+ var classname = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
29
+ try {
30
+ var doc = document.createElement("div");
31
+ doc.innerHTML = html;
32
+ var dom = doc.children;
33
+ doc = null;
34
+ if (dom.length > 0) {
35
+ dom = dom[0];
36
+ classname && util.addClass(dom, classname);
37
+ if (attrs) {
38
+ Object.keys(attrs).forEach(function(key) {
39
+ dom.setAttribute(key, attrs[key]);
40
+ });
41
+ }
42
+ return dom;
43
+ }
44
+ return null;
45
+ } catch (err) {
46
+ XG_DEBUG.logError("util.createDomFromHtml", err);
47
+ return null;
48
+ }
49
+ };
50
+ util.hasClass = function(el, className) {
51
+ if (!el || !className) {
52
+ return false;
53
+ }
54
+ try {
55
+ return Array.prototype.some.call(el.classList, function(item) {
56
+ return item === className;
57
+ });
58
+ } catch (e) {
59
+ var orgClassName = el.className && _typeof(el.className) === "object" ? el.getAttribute("class") : el.className;
60
+ return orgClassName && !!orgClassName.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));
61
+ }
62
+ };
63
+ util.addClass = function(el, className) {
64
+ if (!el || !className) {
65
+ return;
66
+ }
67
+ try {
68
+ className.replace(/(^\s+|\s+$)/g, "").split(/\s+/g).forEach(function(item) {
69
+ item && el.classList.add(item);
70
+ });
71
+ } catch (e) {
72
+ if (!util.hasClass(el, className)) {
73
+ if (el.className && _typeof(el.className) === "object") {
74
+ el.setAttribute("class", el.getAttribute("class") + " " + className);
75
+ } else {
76
+ el.className += " " + className;
77
+ }
78
+ }
79
+ }
80
+ };
81
+ util.removeClass = function(el, className) {
82
+ if (!el || !className) {
83
+ return;
84
+ }
85
+ try {
86
+ className.replace(/(^\s+|\s+$)/g, "").split(/\s+/g).forEach(function(item) {
87
+ item && el.classList.remove(item);
88
+ });
89
+ } catch (e) {
90
+ if (util.hasClass(el, className)) {
91
+ className.split(/\s+/g).forEach(function(item) {
92
+ var reg = new RegExp("(\\s|^)" + item + "(\\s|$)");
93
+ if (el.className && _typeof(el.className) === "object") {
94
+ el.setAttribute("class", el.getAttribute("class").replace(reg, " "));
95
+ } else {
96
+ el.className = el.className.replace(reg, " ");
97
+ }
98
+ });
99
+ }
100
+ }
101
+ };
102
+ util.toggleClass = function(el, className) {
103
+ if (!el) {
104
+ return;
105
+ }
106
+ className.split(/\s+/g).forEach(function(item) {
107
+ if (util.hasClass(el, item)) {
108
+ util.removeClass(el, item);
109
+ } else {
110
+ util.addClass(el, item);
111
+ }
112
+ });
113
+ };
114
+ util.classNames = function() {
115
+ var _arguments = arguments;
116
+ var classname = [];
117
+ var _loop = function _loop2(i2) {
118
+ if (util.typeOf(_arguments[i2]) === "String") {
119
+ classname.push(_arguments[i2]);
120
+ } else if (util.typeOf(_arguments[i2]) === "Object") {
121
+ Object.keys(_arguments[i2]).map(function(key) {
122
+ if (_arguments[i2][key]) {
123
+ classname.push(key);
124
+ }
125
+ });
126
+ }
127
+ };
128
+ for (var i = 0; i < arguments.length; i++) {
129
+ _loop(i);
130
+ }
131
+ return classname.join(" ");
132
+ };
133
+ util.findDom = function() {
134
+ var el = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : document;
135
+ var sel = arguments.length > 1 ? arguments[1] : void 0;
136
+ var dom;
137
+ try {
138
+ dom = el.querySelector(sel);
139
+ } catch (e) {
140
+ XG_DEBUG.logError("util.findDom", e);
141
+ if (sel.indexOf("#") === 0) {
142
+ dom = el.getElementById(sel.slice(1));
143
+ }
144
+ }
145
+ return dom;
146
+ };
147
+ util.getCss = function(dom, key) {
148
+ return dom.currentStyle ? dom.currentStyle[key] : document.defaultView.getComputedStyle(dom, false)[key];
149
+ };
150
+ util.padStart = function(str, length, pad) {
151
+ var charstr = String(pad);
152
+ var len = length >> 0;
153
+ var maxlen = Math.ceil(len / charstr.length);
154
+ var chars = [];
155
+ var r = String(str);
156
+ while (maxlen--) {
157
+ chars.push(charstr);
158
+ }
159
+ return chars.join("").substring(0, len - r.length) + r;
160
+ };
161
+ util.format = function(time) {
162
+ if (window.isNaN(time)) {
163
+ return "";
164
+ }
165
+ time = Math.round(time);
166
+ var hour = util.padStart(Math.floor(time / 3600), 2, 0);
167
+ var minute = util.padStart(Math.floor((time - hour * 3600) / 60), 2, 0);
168
+ var second = util.padStart(Math.floor(time - hour * 3600 - minute * 60), 2, 0);
169
+ return (hour === "00" ? [minute, second] : [hour, minute, second]).join(":");
170
+ };
171
+ util.event = function(e) {
172
+ if (e.touches) {
173
+ var touch = e.touches[0] || e.changedTouches[0];
174
+ e.clientX = touch.clientX || 0;
175
+ e.clientY = touch.clientY || 0;
176
+ e.offsetX = touch.pageX - touch.target.offsetLeft;
177
+ e.offsetY = touch.pageY - touch.target.offsetTop;
178
+ }
179
+ e._target = e.target || e.srcElement;
180
+ };
181
+ util.typeOf = function(obj) {
182
+ return Object.prototype.toString.call(obj).match(/([^\s.*]+)(?=]$)/g)[0];
183
+ };
184
+ util.deepCopy = function(dst, src) {
185
+ if (util.typeOf(src) === "Object" && util.typeOf(dst) === "Object") {
186
+ Object.keys(src).forEach(function(key) {
187
+ if (util.typeOf(src[key]) === "Object" && !(src[key] instanceof Node)) {
188
+ if (dst[key] === void 0 || dst[key] === void 0) {
189
+ dst[key] = src[key];
190
+ } else {
191
+ util.deepCopy(dst[key], src[key]);
192
+ }
193
+ } else if (util.typeOf(src[key]) === "Array") {
194
+ dst[key] = util.typeOf(dst[key]) === "Array" ? dst[key].concat(src[key]) : src[key];
195
+ } else {
196
+ dst[key] = src[key];
197
+ }
198
+ });
199
+ return dst;
200
+ }
201
+ };
202
+ util.deepMerge = function(dst, src) {
203
+ Object.keys(src).map(function(key) {
204
+ if (util.typeOf(src[key]) === "Array" && util.typeOf(dst[key]) === "Array") {
205
+ if (util.typeOf(dst[key]) === "Array") {
206
+ var _dst$key;
207
+ (_dst$key = dst[key]).push.apply(_dst$key, _toConsumableArray(src[key]));
208
+ }
209
+ } else if (util.typeOf(dst[key]) === util.typeOf(src[key]) && dst[key] !== null && util.typeOf(dst[key]) === "Object" && !(src[key] instanceof window.Node)) {
210
+ util.deepMerge(dst[key], src[key]);
211
+ } else {
212
+ src[key] !== null && (dst[key] = src[key]);
213
+ }
214
+ });
215
+ return dst;
216
+ };
217
+ util.getBgImage = function(el) {
218
+ var url = (el.currentStyle || window.getComputedStyle(el, null)).backgroundImage;
219
+ if (!url || url === "none") {
220
+ return "";
221
+ }
222
+ var a = document.createElement("a");
223
+ a.href = url.replace(/url\("|"\)/g, "");
224
+ return a.href;
225
+ };
226
+ util.copyDom = function(dom) {
227
+ if (dom && dom.nodeType === 1) {
228
+ var back = document.createElement(dom.tagName);
229
+ Array.prototype.forEach.call(dom.attributes, function(node) {
230
+ back.setAttribute(node.name, node.value);
231
+ });
232
+ if (dom.innerHTML) {
233
+ back.innerHTML = dom.innerHTML;
234
+ }
235
+ return back;
236
+ } else {
237
+ return "";
238
+ }
239
+ };
240
+ util.setInterval = function(context, eventName, intervalFunc, frequency) {
241
+ if (!context._interval[eventName]) {
242
+ context._interval[eventName] = window.setInterval(intervalFunc.bind(context), frequency);
243
+ }
244
+ };
245
+ util.clearInterval = function(context, eventName) {
246
+ clearInterval(context._interval[eventName]);
247
+ context._interval[eventName] = null;
248
+ };
249
+ util.setTimeout = function(context, fun, time) {
250
+ if (!context._timers) {
251
+ context._timers = [];
252
+ }
253
+ var id = setTimeout(function() {
254
+ fun();
255
+ util.clearTimeout(context, id);
256
+ }, time);
257
+ context._timers.push(id);
258
+ return id;
259
+ };
260
+ util.clearTimeout = function(context, id) {
261
+ var _timers = context._timers;
262
+ if (util.typeOf(_timers) === "Array") {
263
+ for (var i = 0; i < _timers.length; i++) {
264
+ if (_timers[i] === id) {
265
+ _timers.splice(i, 1);
266
+ clearTimeout(id);
267
+ break;
268
+ }
269
+ }
270
+ } else {
271
+ clearTimeout(id);
272
+ }
273
+ };
274
+ util.clearAllTimers = function(context) {
275
+ var _timers = context._timers;
276
+ if (util.typeOf(_timers) === "Array") {
277
+ _timers.map(function(item) {
278
+ clearTimeout(item);
279
+ });
280
+ context._timerIds = [];
281
+ }
282
+ };
283
+ util.createImgBtn = function(name, imgUrl, width, height) {
284
+ var btn = util.createDom("xg-".concat(name), "", {}, "xgplayer-".concat(name, "-img"));
285
+ btn.style.backgroundImage = 'url("'.concat(imgUrl, '")');
286
+ if (width && height) {
287
+ var w, h, unit;
288
+ ["px", "rem", "em", "pt", "dp", "vw", "vh", "vm", "%"].every(function(item) {
289
+ if (width.indexOf(item) > -1 && height.indexOf(item) > -1) {
290
+ w = parseFloat(width.slice(0, width.indexOf(item)).trim());
291
+ h = parseFloat(height.slice(0, height.indexOf(item)).trim());
292
+ unit = item;
293
+ return false;
294
+ } else {
295
+ return true;
296
+ }
297
+ });
298
+ btn.style.width = "".concat(w).concat(unit);
299
+ btn.style.height = "".concat(h).concat(unit);
300
+ btn.style.backgroundSize = "".concat(w).concat(unit, " ").concat(h).concat(unit);
301
+ if (name === "start") {
302
+ btn.style.margin = "-".concat(h / 2).concat(unit, " auto auto -").concat(w / 2).concat(unit);
303
+ } else {
304
+ btn.style.margin = "auto 5px auto 5px";
305
+ }
306
+ }
307
+ return btn;
308
+ };
309
+ util.Hex2RGBA = function(hex, alpha) {
310
+ var rgb = [];
311
+ if (/^\#[0-9A-F]{3}$/i.test(hex)) {
312
+ var sixHex = "#";
313
+ hex.replace(/[0-9A-F]/ig, function(kw) {
314
+ sixHex += kw + kw;
315
+ });
316
+ hex = sixHex;
317
+ }
318
+ if (/^#[0-9A-F]{6}$/i.test(hex)) {
319
+ hex.replace(/[0-9A-F]{2}/ig, function(kw) {
320
+ rgb.push(parseInt(kw, 16));
321
+ });
322
+ return "rgba(".concat(rgb.join(","), ", ").concat(alpha, ")");
323
+ } else {
324
+ return "rgba(255, 255, 255, 0.1)";
325
+ }
326
+ };
327
+ util.getFullScreenEl = function() {
328
+ return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
329
+ };
330
+ util.checkIsFunction = function(fun) {
331
+ return fun && typeof fun === "function";
332
+ };
333
+ util.checkIsObject = function(obj) {
334
+ return obj !== null && _typeof(obj) === "object";
335
+ };
336
+ util.hide = function(dom) {
337
+ dom.style.display = "none";
338
+ };
339
+ util.show = function(dom, display) {
340
+ dom.style.display = display || "block";
341
+ };
342
+ util.isUndefined = function(val) {
343
+ if (typeof val === "undefined" || val === null) {
344
+ return true;
345
+ }
346
+ };
347
+ util.isNotNull = function(val) {
348
+ return !(val === void 0 || val === null);
349
+ };
350
+ util.setStyleFromCsstext = function(dom, text) {
351
+ if (!text) {
352
+ return;
353
+ }
354
+ if (util.typeOf(text) === "String") {
355
+ var styleArr = text.replace(/\s+/g, "").split(";");
356
+ styleArr.map(function(item) {
357
+ if (item) {
358
+ var arr = item.split(":");
359
+ if (arr.length > 1) {
360
+ dom.style[arr[0]] = arr[1];
361
+ }
362
+ }
363
+ });
364
+ } else {
365
+ Object.keys(text).map(function(key) {
366
+ dom.style[key] = text[key];
367
+ });
368
+ }
369
+ };
370
+ function checkIsIn(key, list) {
371
+ for (var i = 0, len = list.length; i < len; i++) {
372
+ if (key.indexOf(list[i]) > -1) {
373
+ return true;
374
+ }
375
+ }
376
+ return false;
377
+ }
378
+ util.filterStyleFromText = function(dom) {
379
+ var list = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["width", "height", "top", "left", "bottom", "right", "position", "z-index", "padding", "margin", "transform"];
380
+ var _cssText = dom.style.cssText;
381
+ if (!_cssText) {
382
+ return {};
383
+ }
384
+ var styleArr = _cssText.replace(/\s+/g, "").split(";");
385
+ var ret = {};
386
+ var remain = {};
387
+ styleArr.map(function(item) {
388
+ if (item) {
389
+ var arr = item.split(":");
390
+ if (arr.length > 1) {
391
+ if (checkIsIn(arr[0], list)) {
392
+ ret[arr[0]] = arr[1];
393
+ } else {
394
+ remain[arr[0]] = arr[1];
395
+ }
396
+ }
397
+ }
398
+ });
399
+ dom.setAttribute("style", "");
400
+ Object.keys(remain).map(function(key) {
401
+ dom.style[key] = remain[key];
402
+ });
403
+ return ret;
404
+ };
405
+ util.getStyleFromCsstext = function(dom) {
406
+ var _cssText = dom.style.cssText;
407
+ if (!_cssText) {
408
+ return {};
409
+ }
410
+ var styleArr = _cssText.replace(/\s+/g, "").split(";");
411
+ var ret = {};
412
+ styleArr.map(function(item) {
413
+ if (item) {
414
+ var arr = item.split(":");
415
+ if (arr.length > 1) {
416
+ ret[arr[0]] = arr[1];
417
+ }
418
+ }
419
+ });
420
+ return ret;
421
+ };
422
+ util.preloadImg = function(url) {
423
+ var onload = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function() {
424
+ };
425
+ var onerror = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
426
+ };
427
+ if (!url) {
428
+ return;
429
+ }
430
+ var img = new window.Image();
431
+ img.onload = function(e) {
432
+ img = null;
433
+ onload && onload(e);
434
+ };
435
+ img.onerror = function(e) {
436
+ img = null;
437
+ onerror && onerror(e);
438
+ };
439
+ img.src = url;
440
+ };
441
+ util.stopPropagation = function(e) {
442
+ if (e) {
443
+ e.stopPropagation();
444
+ }
445
+ };
446
+ util.scrollTop = function() {
447
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
448
+ };
449
+ util.scrollLeft = function() {
450
+ return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
451
+ };
452
+ util.checkTouchSupport = function() {
453
+ return "ontouchstart" in window;
454
+ };
455
+ util.getBuffered2 = function(vbuffered) {
456
+ var maxHoleDuration = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0.5;
457
+ var buffered = [];
458
+ for (var i = 0; i < vbuffered.length; i++) {
459
+ buffered.push({
460
+ start: vbuffered.start(i) < 0.5 ? 0 : vbuffered.start(i),
461
+ end: vbuffered.end(i)
462
+ });
463
+ }
464
+ buffered.sort(function(a, b) {
465
+ var diff = a.start - b.start;
466
+ if (diff) {
467
+ return diff;
468
+ } else {
469
+ return b.end - a.end;
470
+ }
471
+ });
472
+ var buffered2 = [];
473
+ if (maxHoleDuration) {
474
+ for (var _i = 0; _i < buffered.length; _i++) {
475
+ var buf2len = buffered2.length;
476
+ if (buf2len) {
477
+ var buf2end = buffered2[buf2len - 1].end;
478
+ if (buffered[_i].start - buf2end < maxHoleDuration) {
479
+ if (buffered[_i].end > buf2end) {
480
+ buffered2[buf2len - 1].end = buffered[_i].end;
481
+ }
482
+ } else {
483
+ buffered2.push(buffered[_i]);
484
+ }
485
+ } else {
486
+ buffered2.push(buffered[_i]);
487
+ }
488
+ }
489
+ } else {
490
+ buffered2 = buffered;
491
+ }
492
+ return new XgplayerTimeRange(buffered2);
493
+ };
494
+ util.getEventPos = function(e) {
495
+ var zoom = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
496
+ if (e.touches && e.touches.length > 0) {
497
+ e = e.touches[0];
498
+ }
499
+ return {
500
+ x: e.x / zoom,
501
+ y: e.y / zoom,
502
+ clientX: e.clientX / zoom,
503
+ clientY: e.clientY / zoom,
504
+ offsetX: e.offsetX / zoom,
505
+ offsetY: e.offsetY / zoom,
506
+ pageX: e.pageX / zoom,
507
+ pageY: e.pageY / zoom
508
+ };
509
+ };
510
+ util.requestAnimationFrame = function(callback) {
511
+ var _fun = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame;
512
+ if (_fun) {
513
+ return _fun(callback);
514
+ }
515
+ };
516
+ util.getHostFromUrl = function(url) {
517
+ if (util.typeOf(url) !== "String") {
518
+ return "";
519
+ }
520
+ var results = url.split("/");
521
+ var domain = "";
522
+ if (results.length > 3 && results[2]) {
523
+ domain = results[2];
524
+ }
525
+ return domain;
526
+ };
527
+ util.cancelAnimationFrame = function(frameId) {
528
+ var _fun = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.cancelRequestAnimationFrame;
529
+ _fun && _fun(frameId);
530
+ };
531
+ util.isMSE = function(video) {
532
+ if (!video || !(video instanceof HTMLMediaElement)) {
533
+ return false;
534
+ }
535
+ return /^blob/.test(video.currentSrc) || /^blob/.test(video.src);
536
+ };
537
+ util.isBlob = function(url) {
538
+ return /^blob/.test(url);
539
+ };
540
+ util.generateSessionId = function() {
541
+ var did = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
542
+ var d = new Date().getTime();
543
+ try {
544
+ did = parseInt(did);
545
+ } catch (e) {
546
+ did = 0;
547
+ }
548
+ d += did;
549
+ if (window.performance && typeof window.performance.now === "function") {
550
+ d += parseInt(window.performance.now());
551
+ }
552
+ var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
553
+ var r = (d + Math.random() * 16) % 16 | 0;
554
+ d = Math.floor(d / 16);
555
+ return (c === "x" ? r : r & 3 | 8).toString(16);
556
+ });
557
+ return uuid;
558
+ };
559
+ util.createEvent = function(eventName) {
560
+ var event;
561
+ if (typeof window.Event === "function") {
562
+ event = new Event(eventName);
563
+ } else {
564
+ event = document.createEvent("Event");
565
+ event.initEvent(eventName, true, true);
566
+ }
567
+ return event;
568
+ };
569
+ util.adjustTimeByDuration = function(time, duration, isEnded) {
570
+ if (!duration || !time) {
571
+ return time;
572
+ }
573
+ if (time > duration || isEnded && time < duration) {
574
+ return duration;
575
+ }
576
+ return time;
577
+ };
578
+ util.createPositionBar = function(className, root) {
579
+ var dom = util.createDom("xg-bar", "", {
580
+ "data-index": -1
581
+ }, className);
582
+ root.appendChild(dom);
583
+ return dom;
584
+ };
585
+ util.getTransformStyle = function() {
586
+ var pos = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
587
+ x: 0,
588
+ y: 0,
589
+ scale: 1,
590
+ rotate: 0
591
+ };
592
+ var transformValue = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
593
+ var styles = {
594
+ scale: "".concat(pos.scale || 1),
595
+ translate: "".concat(pos.x || 0, "%, ").concat(pos.y || 0, "%"),
596
+ rotate: "".concat(pos.rotate || 0, "deg")
597
+ };
598
+ var stylesKeys = Object.keys(styles);
599
+ stylesKeys.forEach(function(key) {
600
+ var reg = new RegExp("".concat(key, "\\([^\\(]+\\)"), "g");
601
+ var fn = "".concat(key, "(").concat(styles[key], ")");
602
+ if (reg.test(transformValue)) {
603
+ reg.lastIndex = -1;
604
+ transformValue = transformValue.replace(reg, fn);
605
+ } else {
606
+ transformValue += "".concat(fn, " ");
607
+ }
608
+ });
609
+ return transformValue;
610
+ };
611
+ util.convertDeg = function(val) {
612
+ if (Math.abs(val) <= 1) {
613
+ return val * 360;
614
+ }
615
+ return val % 360;
616
+ };
617
+ util.getIndexByTime = function(time, segments) {
618
+ var _len = segments.length;
619
+ var _index = -1;
620
+ if (_len < 1) {
621
+ return _index;
622
+ }
623
+ if (time <= segments[0].end || _len < 2) {
624
+ _index = 0;
625
+ } else if (time > segments[_len - 1].end) {
626
+ _index = _len - 1;
627
+ } else {
628
+ for (var i = 1; i < _len; i++) {
629
+ if (time > segments[i - 1].end && time <= segments[i].end) {
630
+ _index = i;
631
+ break;
632
+ }
633
+ }
634
+ }
635
+ return _index;
636
+ };
637
+ util.getOffsetCurrentTime = function(currentTime, segments) {
638
+ var index = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : -1;
639
+ var _index = -1;
640
+ if (index >= 0 && index < segments.length) {
641
+ _index = index;
642
+ } else {
643
+ _index = util.getIndexByTime(currentTime, segments);
644
+ }
645
+ if (_index < 0) {
646
+ return -1;
647
+ }
648
+ var _len = segments.length;
649
+ var _segments$_index = segments[_index], start = _segments$_index.start, end = _segments$_index.end, cTime = _segments$_index.cTime, offset = _segments$_index.offset;
650
+ if (currentTime < start) {
651
+ return cTime;
652
+ } else if (currentTime >= start && currentTime <= end) {
653
+ return currentTime - offset;
654
+ } else if (currentTime > end && _index >= _len - 1) {
655
+ return end;
656
+ }
657
+ return -1;
658
+ };
659
+ util.getCurrentTimeByOffset = function(offsetTime, segments) {
660
+ var _index = -1;
661
+ if (!segments || segments.length < 0) {
662
+ return offsetTime;
663
+ }
664
+ for (var i = 0; i < segments.length; i++) {
665
+ if (offsetTime <= segments[i].duration) {
666
+ _index = i;
667
+ break;
668
+ }
669
+ }
670
+ if (_index !== -1) {
671
+ var start = segments[_index].start;
672
+ if (_index - 1 < 0) {
673
+ return start + offsetTime;
674
+ } else {
675
+ return start + (offsetTime - segments[_index - 1].duration);
676
+ }
677
+ }
678
+ return offsetTime;
679
+ };
680
+ function isObject(value) {
681
+ var type = _typeof(value);
682
+ return value !== null && (type === "object" || type === "function");
683
+ }
684
+ function debounce(func, wait, options) {
685
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
686
+ var lastInvokeTime = 0;
687
+ var leading = false;
688
+ var maxing = false;
689
+ var trailing = true;
690
+ var useRAF = !wait && wait !== 0 && typeof window.requestAnimationFrame === "function";
691
+ if (typeof func !== "function") {
692
+ throw new TypeError("Expected a function");
693
+ }
694
+ wait = +wait || 0;
695
+ if (isObject(options)) {
696
+ leading = !!options.leading;
697
+ maxing = "maxWait" in options;
698
+ maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait;
699
+ trailing = "trailing" in options ? !!options.trailing : trailing;
700
+ }
701
+ function invokeFunc(time) {
702
+ var args = lastArgs;
703
+ var thisArg = lastThis;
704
+ lastArgs = lastThis = void 0;
705
+ lastInvokeTime = time;
706
+ result = func.apply(thisArg, args);
707
+ return result;
708
+ }
709
+ function startTimer(pendingFunc, wait2) {
710
+ if (useRAF) {
711
+ window.cancelAnimationFrame(timerId);
712
+ return window.requestAnimationFrame(pendingFunc);
713
+ }
714
+ return setTimeout(pendingFunc, wait2);
715
+ }
716
+ function cancelTimer(id) {
717
+ if (useRAF) {
718
+ return window.cancelAnimationFrame(id);
719
+ }
720
+ clearTimeout(id);
721
+ }
722
+ function leadingEdge(time) {
723
+ lastInvokeTime = time;
724
+ timerId = startTimer(timerExpired, wait);
725
+ return leading ? invokeFunc(time) : result;
726
+ }
727
+ function remainingWait(time) {
728
+ var timeSinceLastCall = time - lastCallTime;
729
+ var timeSinceLastInvoke = time - lastInvokeTime;
730
+ var timeWaiting = wait - timeSinceLastCall;
731
+ return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
732
+ }
733
+ function shouldInvoke(time) {
734
+ var timeSinceLastCall = time - lastCallTime;
735
+ var timeSinceLastInvoke = time - lastInvokeTime;
736
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
737
+ }
738
+ function timerExpired() {
739
+ var time = Date.now();
740
+ if (shouldInvoke(time)) {
741
+ return trailingEdge(time);
742
+ }
743
+ timerId = startTimer(timerExpired, remainingWait(time));
744
+ }
745
+ function trailingEdge(time) {
746
+ timerId = void 0;
747
+ if (trailing && lastArgs) {
748
+ return invokeFunc(time);
749
+ }
750
+ lastArgs = lastThis = void 0;
751
+ return result;
752
+ }
753
+ function cancel() {
754
+ if (timerId !== void 0) {
755
+ cancelTimer(timerId);
756
+ }
757
+ lastInvokeTime = 0;
758
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
759
+ }
760
+ function flush() {
761
+ return timerId === void 0 ? result : trailingEdge(Date.now());
762
+ }
763
+ function pending() {
764
+ return timerId !== void 0;
765
+ }
766
+ function debounced() {
767
+ var time = Date.now();
768
+ var isInvoking = shouldInvoke(time);
769
+ for (var _len2 = arguments.length, args = new Array(_len2), _key = 0; _key < _len2; _key++) {
770
+ args[_key] = arguments[_key];
771
+ }
772
+ lastArgs = args;
773
+ lastThis = this;
774
+ lastCallTime = time;
775
+ if (isInvoking) {
776
+ if (timerId === void 0) {
777
+ return leadingEdge(lastCallTime);
778
+ }
779
+ if (maxing) {
780
+ timerId = startTimer(timerExpired, wait);
781
+ return invokeFunc(lastCallTime);
782
+ }
783
+ }
784
+ if (timerId === void 0) {
785
+ timerId = startTimer(timerExpired, wait);
786
+ }
787
+ return result;
788
+ }
789
+ debounced.cancel = cancel;
790
+ debounced.flush = flush;
791
+ debounced.pending = pending;
792
+ return debounced;
793
+ }
794
+ function throttle(func, wait, options) {
795
+ var leading = true;
796
+ var trailing = true;
797
+ if (typeof func !== "function") {
798
+ throw new TypeError("Expected a function");
799
+ }
800
+ if (isObject(options)) {
801
+ leading = "leading" in options ? !!options.leading : leading;
802
+ trailing = "trailing" in options ? !!options.trailing : trailing;
803
+ }
804
+ return debounce(func, wait, {
805
+ leading,
806
+ trailing,
807
+ maxWait: wait
808
+ });
809
+ }
810
+ function getLang() {
811
+ var lang = (document.documentElement.getAttribute("lang") || navigator.language || "zh-cn").toLocaleLowerCase();
812
+ if (lang === "zh-cn") {
813
+ lang = "zh";
814
+ }
815
+ return lang;
816
+ }
817
+ function checkIsCurrentVideo(element, playerId, key) {
818
+ if (!element) {
819
+ return;
820
+ }
821
+ var pid = element.getAttribute(key);
822
+ if (pid && pid === playerId && (element.tagName === "VIDEO" || element.tagName === "AUDIO")) {
823
+ return true;
824
+ }
825
+ return false;
826
+ }
827
+ export { checkIsCurrentVideo, debounce, util as default, getLang, throttle };