xgplayer 3.0.0-next.3 → 3.0.0-next.30

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 (253) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/dist/index.min.css +1 -0
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/es/_virtual/_rollupPluginBabelHelpers.js +14 -0
  6. package/es/constant.js +3 -4
  7. package/es/defaultConfig.d.ts +1 -194
  8. package/es/defaultConfig.js +28 -152
  9. package/es/error.d.ts +2 -0
  10. package/es/error.js +59 -106
  11. package/es/events.d.ts +8 -0
  12. package/es/events.js +58 -59
  13. package/es/icons.d.ts +2 -0
  14. package/es/index.css +74 -1695
  15. package/es/index.d.ts +12 -0
  16. package/es/index.js +22 -11
  17. package/es/index.scss +29 -0
  18. package/es/index.umd.d.ts +4 -2
  19. package/es/index.umd.js +16 -49
  20. package/es/lang/en.js +46 -47
  21. package/es/lang/i18n.js +27 -80
  22. package/es/lang/index.d.ts +2 -0
  23. package/es/lang/jp.js +46 -47
  24. package/es/lang/zh-cn.js +46 -47
  25. package/es/lang/zh-hk.js +46 -47
  26. package/es/player.d.ts +159 -45
  27. package/es/player.js +1449 -2282
  28. package/es/plugin/basePlugin.d.ts +21 -9
  29. package/es/plugin/basePlugin.js +152 -378
  30. package/es/plugin/hooksDescriptor.d.ts +4 -3
  31. package/es/plugin/hooksDescriptor.js +61 -123
  32. package/es/plugin/plugin.d.ts +16 -20
  33. package/es/plugin/plugin.js +379 -734
  34. package/es/plugin/pluginsManager.d.ts +28 -4
  35. package/es/plugin/pluginsManager.js +137 -235
  36. package/es/plugin/preset.js +13 -31
  37. package/es/plugin/resizeObserver.js +66 -103
  38. package/es/plugins/assets/back.js +4 -0
  39. package/es/plugins/assets/download.js +4 -0
  40. package/es/plugins/assets/exitCssFull.js +4 -0
  41. package/es/plugins/assets/exitFull.js +4 -0
  42. package/es/plugins/assets/loading.js +4 -0
  43. package/es/plugins/assets/panel.js +4 -0
  44. package/es/plugins/assets/pause.js +4 -0
  45. package/es/plugins/assets/pipIcon.js +4 -0
  46. package/es/plugins/assets/pipIconExit.js +4 -0
  47. package/es/plugins/assets/play.js +4 -0
  48. package/es/plugins/assets/playNext.js +4 -0
  49. package/es/plugins/assets/replay.js +4 -0
  50. package/es/plugins/assets/requestCssFull.js +7 -0
  51. package/es/plugins/assets/requestFull.js +4 -0
  52. package/es/plugins/assets/rotate.js +4 -0
  53. package/es/plugins/assets/seekicon.js +4 -0
  54. package/es/plugins/assets/volumeLarge.js +4 -0
  55. package/es/plugins/assets/volumeMuted.js +4 -0
  56. package/es/plugins/assets/volumeSmall.js +4 -0
  57. package/es/plugins/common/iconPlugin.d.ts +5 -0
  58. package/es/plugins/common/iconPlugin.js +30 -0
  59. package/es/plugins/common/index.scss +2 -0
  60. package/es/plugins/common/optionList.d.ts +2 -2
  61. package/es/plugins/common/optionList.js +80 -115
  62. package/es/plugins/common/optionsIcon.css +0 -1
  63. package/es/plugins/common/optionsIcon.d.ts +4 -2
  64. package/es/plugins/common/optionsIcon.js +174 -239
  65. package/es/plugins/common/optionsIcon.scss +121 -0
  66. package/es/plugins/common/thumbnail.d.ts +5 -3
  67. package/es/plugins/common/thumbnail.js +149 -223
  68. package/es/plugins/common/thumbnail.scss +27 -0
  69. package/es/plugins/controls/index.css +4 -10
  70. package/es/plugins/controls/index.d.ts +19 -1
  71. package/es/plugins/controls/index.js +164 -294
  72. package/es/plugins/controls/index.scss +199 -0
  73. package/es/plugins/cssFullScreen/index.d.ts +15 -9
  74. package/es/plugins/cssFullScreen/index.js +97 -143
  75. package/es/plugins/cssFullScreen/index.scss +19 -0
  76. package/es/plugins/danmu/danmuIcon.d.ts +11 -0
  77. package/es/plugins/danmu/danmuIcon.js +75 -111
  78. package/es/plugins/danmu/danmuPanel.d.ts +1 -0
  79. package/es/plugins/danmu/danmuPanel.js +127 -113
  80. package/es/plugins/danmu/index.d.ts +1 -0
  81. package/es/plugins/danmu/index.js +252 -402
  82. package/es/plugins/danmu/index.scss +356 -0
  83. package/es/plugins/definition/index.d.ts +2 -0
  84. package/es/plugins/definition/index.js +121 -257
  85. package/es/plugins/definition/index.scss +4 -0
  86. package/es/plugins/download/index.d.ts +6 -2
  87. package/es/plugins/download/index.js +68 -121
  88. package/es/plugins/download/index.scss +22 -0
  89. package/es/plugins/dynamicBg/index.css +1 -1
  90. package/es/plugins/dynamicBg/index.d.ts +22 -6
  91. package/es/plugins/dynamicBg/index.js +229 -370
  92. package/es/plugins/dynamicBg/index.scss +19 -0
  93. package/es/plugins/enter/index.js +32 -74
  94. package/es/plugins/enter/index.scss +78 -0
  95. package/es/plugins/error/index.css +0 -1
  96. package/es/plugins/error/index.d.ts +2 -1
  97. package/es/plugins/error/index.js +63 -100
  98. package/es/plugins/error/index.scss +34 -0
  99. package/es/plugins/fullscreen/backicon.d.ts +8 -0
  100. package/es/plugins/fullscreen/backicon.js +49 -89
  101. package/es/plugins/fullscreen/index.css +1 -1
  102. package/es/plugins/fullscreen/index.d.ts +14 -25
  103. package/es/plugins/fullscreen/index.js +157 -329
  104. package/es/plugins/fullscreen/index.scss +35 -0
  105. package/es/plugins/gapJump/index.d.ts +21 -0
  106. package/es/plugins/gapJump/index.js +128 -0
  107. package/es/plugins/keyboard/index.d.ts +1 -0
  108. package/es/plugins/keyboard/index.js +261 -350
  109. package/es/plugins/loading/index.css +1 -5
  110. package/es/plugins/loading/index.d.ts +4 -0
  111. package/es/plugins/loading/index.js +26 -60
  112. package/es/plugins/loading/index.scss +70 -0
  113. package/es/plugins/logger/index.d.ts +16 -12
  114. package/es/plugins/logger/index.js +209 -208
  115. package/es/plugins/miniScreen/index.css +1 -4
  116. package/es/plugins/miniScreen/index.d.ts +13 -1
  117. package/es/plugins/miniScreen/index.js +178 -262
  118. package/es/plugins/miniScreen/index.scss +198 -0
  119. package/es/plugins/miniScreen/miniScreenIcon.d.ts +1 -0
  120. package/es/plugins/miniScreen/miniScreenIcon.js +37 -72
  121. package/es/plugins/mobile/index.css +24 -1
  122. package/es/plugins/mobile/index.d.ts +8 -1
  123. package/es/plugins/mobile/index.js +523 -741
  124. package/es/plugins/mobile/index.scss +180 -0
  125. package/es/plugins/mobile/touch.d.ts +1 -0
  126. package/es/plugins/mobile/touch.js +168 -230
  127. package/es/plugins/netAdaption/index.d.ts +5 -0
  128. package/es/plugins/pc/index.js +148 -216
  129. package/es/plugins/pc/index.scss +5 -0
  130. package/es/plugins/pip/index.d.ts +14 -2
  131. package/es/plugins/pip/index.js +178 -263
  132. package/es/plugins/pip/index.scss +21 -0
  133. package/es/plugins/play/index.d.ts +13 -2
  134. package/es/plugins/play/index.js +103 -137
  135. package/es/plugins/play/index.scss +18 -0
  136. package/es/plugins/playNext/index.d.ts +4 -0
  137. package/es/plugins/playNext/index.js +79 -113
  138. package/es/plugins/playNext/index.scss +35 -0
  139. package/es/plugins/playbackRate/index.d.ts +3 -0
  140. package/es/plugins/playbackRate/index.js +90 -152
  141. package/es/plugins/playbackRate/index.scss +6 -0
  142. package/es/plugins/poster/index.d.ts +3 -0
  143. package/es/plugins/poster/index.js +76 -140
  144. package/es/plugins/poster/index.scss +56 -0
  145. package/es/plugins/progress/index.css +1 -2
  146. package/es/plugins/progress/index.d.ts +22 -8
  147. package/es/plugins/progress/index.js +500 -700
  148. package/es/plugins/progress/index.scss +278 -0
  149. package/es/plugins/progress/innerList.d.ts +8 -8
  150. package/es/plugins/progress/innerList.js +158 -204
  151. package/es/plugins/progress/miniProgress.d.ts +1 -0
  152. package/es/plugins/progress/miniProgress.js +34 -70
  153. package/es/plugins/progressPreview/dotsApi.js +109 -159
  154. package/es/plugins/progressPreview/index.css +15 -7
  155. package/es/plugins/progressPreview/index.d.ts +22 -6
  156. package/es/plugins/progressPreview/index.js +430 -363
  157. package/es/plugins/progressPreview/index.scss +226 -0
  158. package/es/plugins/prompt/index.css +0 -1
  159. package/es/plugins/prompt/index.d.ts +3 -0
  160. package/es/plugins/prompt/index.js +81 -136
  161. package/es/plugins/prompt/index.scss +53 -0
  162. package/es/plugins/replay/index.d.ts +5 -0
  163. package/es/plugins/replay/index.js +76 -130
  164. package/es/plugins/replay/index.scss +41 -0
  165. package/es/plugins/rotate/index.d.ts +6 -2
  166. package/es/plugins/rotate/index.js +113 -167
  167. package/es/{style/common/svg-url.css → plugins/rotate/index.scss} +0 -0
  168. package/es/plugins/rotate/index2.js +2 -0
  169. package/es/plugins/screenShot/index.d.ts +10 -5
  170. package/es/plugins/screenShot/index.js +120 -165
  171. package/es/plugins/screenShot/index.scss +5 -0
  172. package/es/plugins/start/index.css +2 -7
  173. package/es/plugins/start/index.d.ts +13 -1
  174. package/es/plugins/start/index.js +190 -280
  175. package/es/plugins/start/index.scss +115 -0
  176. package/es/plugins/stats/index.d.ts +38 -0
  177. package/es/plugins/stats/index.js +170 -0
  178. package/es/plugins/testspeed/index.d.ts +20 -0
  179. package/es/plugins/testspeed/index.js +139 -0
  180. package/es/plugins/time/index.css +0 -1
  181. package/es/plugins/time/index.d.ts +7 -4
  182. package/es/plugins/time/index.js +164 -227
  183. package/es/plugins/time/index.scss +39 -0
  184. package/es/plugins/track/index.css +4 -0
  185. package/es/plugins/track/index.d.ts +25 -4
  186. package/es/plugins/track/index.js +265 -308
  187. package/es/plugins/track/index.scss +22 -0
  188. package/es/plugins/volume/index.css +3 -0
  189. package/es/plugins/volume/index.d.ts +31 -0
  190. package/es/plugins/volume/index.js +257 -299
  191. package/es/plugins/volume/index.scss +124 -0
  192. package/es/plugins/waitingTimeoutJump/index.d.ts +15 -0
  193. package/es/plugins/waitingTimeoutJump/index.js +81 -0
  194. package/es/presets/default-en.d.ts +1 -25
  195. package/es/presets/default-en.js +62 -70
  196. package/es/presets/default.d.ts +1 -25
  197. package/es/presets/default.js +66 -71
  198. package/es/presets/index.d.ts +4 -0
  199. package/es/presets/live.d.ts +1 -15
  200. package/es/presets/live.js +37 -48
  201. package/es/presets/mobile.d.ts +1 -24
  202. package/es/presets/mobile.js +33 -40
  203. package/es/proxy.d.ts +53 -10
  204. package/es/proxy.js +400 -751
  205. package/es/state.d.ts +0 -1
  206. package/es/state.js +2 -4
  207. package/es/stateClassMap.d.ts +4 -2
  208. package/es/stateClassMap.js +29 -29
  209. package/es/style/common/animation.scss +16 -0
  210. package/es/style/common/svg-url.scss +70 -0
  211. package/es/style/common.scss +400 -0
  212. package/es/style/index.scss +4 -0
  213. package/es/style/variable.scss +76 -0
  214. package/es/utils/database.js +76 -136
  215. package/es/utils/debug.js +14 -38
  216. package/es/utils/draggabilly.d.ts +1 -1
  217. package/es/utils/draggabilly.js +266 -465
  218. package/es/utils/sniffer.d.ts +5 -0
  219. package/es/utils/sniffer.js +58 -82
  220. package/es/utils/url.d.ts +1 -0
  221. package/es/utils/util.d.ts +12 -11
  222. package/es/utils/util.js +214 -583
  223. package/es/utils/xgplayerTimeRange.js +12 -28
  224. package/es/version.js +1 -5
  225. package/package.json +11 -23
  226. package/dist/xgplayer.min.css +0 -1
  227. package/dist/xgplayer.mobile.min.css +0 -1
  228. package/es/index.mobile.css +0 -1693
  229. package/es/plugins/assets/back.svg.js +0 -5
  230. package/es/plugins/assets/download.svg.js +0 -5
  231. package/es/plugins/assets/exitCssFull.svg.js +0 -5
  232. package/es/plugins/assets/exitFull.svg.js +0 -5
  233. package/es/plugins/assets/loading.svg.js +0 -5
  234. package/es/plugins/assets/panel.svg.js +0 -5
  235. package/es/plugins/assets/pause.svg.js +0 -5
  236. package/es/plugins/assets/pipIcon.svg.js +0 -5
  237. package/es/plugins/assets/pipIconExit.svg.js +0 -5
  238. package/es/plugins/assets/play.svg.js +0 -5
  239. package/es/plugins/assets/playNext.svg.js +0 -5
  240. package/es/plugins/assets/replay.svg.js +0 -5
  241. package/es/plugins/assets/requestCssFull.svg.js +0 -5
  242. package/es/plugins/assets/requestFull.svg.js +0 -5
  243. package/es/plugins/assets/rotate.svg.js +0 -5
  244. package/es/plugins/assets/seekicon.svg.js +0 -5
  245. package/es/plugins/assets/volumeLarge.svg.js +0 -5
  246. package/es/plugins/assets/volumeMuted.svg.js +0 -5
  247. package/es/plugins/assets/volumeSmall.svg.js +0 -5
  248. package/es/plugins/common/index.css +0 -134
  249. package/es/plugins/common/thumbnail.css +0 -3
  250. package/es/style/common/animation.css +0 -32
  251. package/es/style/common.css +0 -314
  252. package/es/style/index.css +0 -449
  253. package/es/style/variable.css +0 -0
@@ -1,789 +1,589 @@
1
- import 'core-js/modules/es.reflect.construct.js';
2
- import _typeof from '@babel/runtime/helpers/typeof';
3
- import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
4
- import _createClass from '@babel/runtime/helpers/createClass';
5
- import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
6
- import _inherits from '@babel/runtime/helpers/inherits';
7
- import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
8
- import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
9
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
10
- import 'core-js/modules/es.array.map.js';
11
- import 'core-js/modules/es.array.find.js';
12
- import 'core-js/modules/es.object.keys.js';
13
- import 'core-js/modules/es.array.splice.js';
14
- import 'core-js/modules/es.number.to-fixed.js';
15
- import 'core-js/modules/es.number.constructor.js';
16
- import Util from '../../utils/util.js';
17
- import Sniffer from '../../utils/sniffer.js';
18
- import { TIME_UPDATE, SEEKED, PROGRESS, ENDED, EMPTIED } from '../../events.js';
19
- import Plugin, { POSITIONS } from '../../plugin/plugin.js';
20
- import { STATES } from '../../state.js';
21
- import InnerList from './innerList.js';
22
-
23
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
24
-
25
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
- /**
27
- * @typedef {{
28
- * position?:string,
29
- * disable?: boolean,
30
- * isDragingSeek?: boolean, // 是否在拖拽的过程中更新currentTime
31
- * closeMoveSeek?: boolean, // 是否关闭滑块seek能力
32
- * isPauseMoving?: boolean, // 是否在move的时候暂停视频内容
33
- * isCloseClickSeek?: boolean, // 是否关闭点击进度条的时候seek
34
- * fragments?: Array<{percent: number}>,
35
- * miniMoveStep?: number,
36
- * miniStartStep?: number,
37
- * onMoveStart?: () => any, // 手势开始移动回调,
38
- * onMoveEnd?: () => any, // 手势移动结束回调
39
- * [propName: string]: any
40
- * }} IProgressConfig
41
- */
42
-
43
- /**
44
- * 进度条组件
45
- */
46
-
47
- var Progress = /*#__PURE__*/function (_Plugin) {
48
- _inherits(Progress, _Plugin);
49
-
50
- var _super = _createSuper(Progress);
51
-
52
- function Progress(args) {
53
- var _this;
54
-
55
- _classCallCheck(this, Progress);
56
-
57
- _this = _super.call(this, args);
58
- /**
59
- * @readonly
60
- */
61
-
62
- _defineProperty(_assertThisInitialized(_this), "onMoveOnly", function (e) {
63
- var _assertThisInitialize = _assertThisInitialized(_this),
64
- pos = _assertThisInitialize.pos,
65
- config = _assertThisInitialize.config,
66
- player = _assertThisInitialize.player;
67
-
68
- Util.event(e);
69
-
70
- var _ePos = Util.getEventPos(e, player.zoom);
71
-
72
- var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
73
-
1
+ import { defineProperty as _defineProperty } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
+ import "core-js/modules/es.array.push.js";
3
+ import util from "../../utils/util.js";
4
+ import sniffer from "../../utils/sniffer.js";
5
+ import { DURATION_CHANGE, TIME_UPDATE, SEEKED, PROGRESS, ENDED, EMPTIED } from "../../events.js";
6
+ import "../../utils/debug.js";
7
+ import Plugin, { POSITIONS } from "../../plugin/plugin.js";
8
+ import "core-js/modules/es.error.cause.js";
9
+ import { STATES } from "../../state.js";
10
+ import InnerList from "./innerList.js";
11
+ class Progress extends Plugin {
12
+ static get pluginName() {
13
+ return "progress";
14
+ }
15
+ static get defaultConfig() {
16
+ return {
17
+ position: POSITIONS.CONTROLS_CENTER,
18
+ index: 0,
19
+ disable: false,
20
+ isDragingSeek: true,
21
+ closeMoveSeek: false,
22
+ isPauseMoving: false,
23
+ isCloseClickSeek: false,
24
+ fragments: [{
25
+ percent: 1
26
+ }],
27
+ miniMoveStep: 5,
28
+ miniStartStep: 2,
29
+ onMoveStart: () => {
30
+ },
31
+ onMoveEnd: () => {
32
+ },
33
+ endedDiff: 0.2
34
+ };
35
+ }
36
+ constructor(args) {
37
+ super(args);
38
+ _defineProperty(this, "onMoveOnly", (e) => {
39
+ const {
40
+ pos,
41
+ config,
42
+ player
43
+ } = this;
44
+ util.event(e);
45
+ const _ePos = util.getEventPos(e, player.zoom);
46
+ const x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
74
47
  if (pos.moving && Math.abs(pos.x - x) < config.miniMoveStep) {
75
48
  return;
76
49
  }
77
-
78
50
  pos.moving = true;
79
51
  pos.x = x;
80
-
81
- var ret = _this.computeTime(e);
82
-
83
- _this.triggerCallbacks('dragmove', ret);
52
+ const ret = this.computeTime(e);
53
+ this.triggerCallbacks("dragmove", ret, e);
84
54
  });
85
-
86
- _defineProperty(_assertThisInitialized(_this), "onBodyClick", function (e) {
55
+ _defineProperty(this, "onBodyClick", (e) => {
87
56
  e.preventDefault();
88
57
  e.stopPropagation();
89
58
  });
90
-
91
- _defineProperty(_assertThisInitialized(_this), "onMouseDown", function (e) {
92
- var _assertThisInitialize2 = _assertThisInitialized(_this),
93
- player = _assertThisInitialize2.player,
94
- pos = _assertThisInitialize2.pos,
95
- config = _assertThisInitialize2.config,
96
- playerConfig = _assertThisInitialize2.playerConfig;
97
-
98
- var _ePos = Util.getEventPos(e, player.zoom);
99
-
100
- var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
101
-
59
+ _defineProperty(this, "_mouseDownHandler", (event, data) => {
60
+ this._state.time = data.currentTime;
61
+ this.updateWidth(data.currentTime, data.percent, 0);
62
+ });
63
+ _defineProperty(this, "_mouseUpHandler", (e, data) => {
64
+ const {
65
+ pos
66
+ } = this;
67
+ if (pos.moving) {
68
+ this.updateWidth(data.currentTime, data.percent, 2);
69
+ }
70
+ });
71
+ _defineProperty(this, "_mouseMoveHandler", (e, data) => {
72
+ const {
73
+ _state,
74
+ pos,
75
+ config,
76
+ player
77
+ } = this;
78
+ if (_state.time < data.currentTime) {
79
+ data.forward = true;
80
+ } else {
81
+ data.forward = false;
82
+ }
83
+ _state.time = data.currentTime;
84
+ if (pos.isDown && !pos.moving) {
85
+ pos.moving = true;
86
+ config.isPauseMoving && player.pause();
87
+ this.triggerCallbacks("dragstart", data, e);
88
+ }
89
+ this.updateWidth(data.currentTime, data.percent, 1);
90
+ this.triggerCallbacks("dragmove", data, e);
91
+ });
92
+ _defineProperty(this, "onMouseDown", (e) => {
93
+ const {
94
+ player,
95
+ pos,
96
+ config,
97
+ playerConfig
98
+ } = this;
99
+ const _ePos = util.getEventPos(e, player.zoom);
100
+ const x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
102
101
  if (player.isMini || config.closeMoveSeek || !playerConfig.allowSeekAfterEnded && player.ended) {
103
102
  return;
104
103
  }
105
-
106
104
  e.stopPropagation();
107
- e.preventDefault();
108
-
109
- _this.focus();
110
-
111
- Util.checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
112
- Util.checkIsFunction(config.onMoveStart) && config.onMoveStart();
113
- Util.event(e);
105
+ this.focus();
106
+ util.checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
107
+ util.checkIsFunction(config.onMoveStart) && config.onMoveStart();
108
+ util.event(e);
114
109
  pos.x = x;
115
110
  pos.isDown = true;
116
- pos.moving = false; // 交互开始 禁止控制栏的自动隐藏功能
117
-
111
+ pos.moving = false;
118
112
  player.focus({
119
113
  autoHide: false
120
114
  });
121
- _this.isProgressMoving = true;
122
- Util.addClass(_this.progressBtn, 'active');
123
-
124
- var ret = _this.computeTime(e);
125
-
126
- _this._state.time = ret.currentTime;
127
-
128
- _this.updateWidth(ret.currentTime, ret.percent, 0);
129
-
130
- if (_this.isMobile) {
131
- _this.bind('touchmove', _this.onMouseMove);
132
-
133
- _this.bind('touchend', _this.onMouseUp);
115
+ this.isProgressMoving = true;
116
+ util.addClass(this.progressBtn, "active");
117
+ const ret = this.computeTime(e);
118
+ this._mouseDownHandlerHook(e, ret);
119
+ if (this.domEventType === "touch") {
120
+ this.root.addEventListener("touchmove", this.onMouseMove);
121
+ this.root.addEventListener("touchend", this.onMouseUp);
134
122
  } else {
135
- _this.unbind('mousemove', _this.onMoveOnly);
136
-
137
- document.addEventListener('mousemove', _this.onMouseMove, false);
138
- document.addEventListener('mouseup', _this.onMouseUp, false); // 避免触发videoClick 暂停/播放切换
139
-
140
- player.root.addEventListener('click', _this.onBodyClick, false); // this.bind('mouseup', this.onMouseUp, false)
123
+ this.unbind("mousemove", this.onMoveOnly);
124
+ document.addEventListener("mousemove", this.onMouseMove, false);
125
+ document.addEventListener("mouseup", this.onMouseUp, false);
126
+ player.root.addEventListener("click", this.onBodyClick, false);
141
127
  }
142
-
143
128
  return true;
144
129
  });
145
-
146
- _defineProperty(_assertThisInitialized(_this), "onMouseUp", function (e) {
147
- var _assertThisInitialize3 = _assertThisInitialized(_this),
148
- player = _assertThisInitialize3.player,
149
- config = _assertThisInitialize3.config,
150
- pos = _assertThisInitialize3.pos,
151
- playerConfig = _assertThisInitialize3.playerConfig,
152
- _state = _assertThisInitialize3._state;
153
-
130
+ _defineProperty(this, "onMouseUp", (e) => {
131
+ const {
132
+ player,
133
+ config,
134
+ pos,
135
+ playerConfig,
136
+ _state
137
+ } = this;
154
138
  e.stopPropagation();
155
139
  e.preventDefault();
156
- Util.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
157
- Util.checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
158
- Util.event(e);
159
- Util.removeClass(_this.progressBtn, 'active');
160
-
161
- var ret = _this.computeTime(e);
162
-
140
+ util.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
141
+ util.checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
142
+ util.event(e);
143
+ util.removeClass(this.progressBtn, "active");
144
+ const ret = this.computeTime(e);
163
145
  if (pos.moving) {
164
- _this.updateWidth(ret.currentTime, ret.percent, 2);
165
-
166
- _this.triggerCallbacks('dragend', ret);
146
+ this.triggerCallbacks("dragend", ret, e);
167
147
  } else {
168
- // this.updateWidth(ret.currentTime, ret.percent, 2)
169
- _this.triggerCallbacks('click', ret);
148
+ this.triggerCallbacks("click", ret, e);
170
149
  }
171
-
150
+ this._mouseUpHandlerHook(e, ret);
172
151
  pos.moving = false;
173
152
  pos.isDown = false;
174
153
  pos.x = 0;
175
154
  pos.y = 0;
176
155
  _state.time = 0;
177
-
178
- if (_this.isMobile) {
179
- _this.unbind('touchmove', _this.onMouseMove);
180
-
181
- _this.unbind('touchend', _this.onMouseUp); // 交互结束 恢复控制栏的隐藏流程
182
-
183
-
184
- _this.blur();
156
+ if (this.domEventType === "touch") {
157
+ this.root.removeEventListener("touchmove", this.onMouseMove);
158
+ this.root.removeEventListener("touchend", this.onMouseUp);
159
+ this.blur();
185
160
  } else {
186
- document.removeEventListener('mousemove', _this.onMouseMove, false);
187
- document.removeEventListener('mouseup', _this.onMouseUp, false);
188
- player.root.removeEventListener('click', _this.onBodyClick, false);
189
-
161
+ document.removeEventListener("mousemove", this.onMouseMove, false);
162
+ document.removeEventListener("mouseup", this.onMouseUp, false);
163
+ player.root.removeEventListener("click", this.onBodyClick, false);
190
164
  if (!pos.isEnter) {
191
- _this.onMouseLeave(e);
165
+ this.onMouseLeave(e);
192
166
  } else {
193
- !playerConfig.isMobileSimulateMode && _this.bind('mousemove', _this.onMoveOnly);
167
+ playerConfig.isMobileSimulateMode !== "mobile" && this.bind("mousemove", this.onMoveOnly);
194
168
  }
195
- } // 延迟复位,状态复位要在dom相关时间回调执行之后
196
-
197
-
198
- Util.setTimeout(_assertThisInitialized(_this), function () {
199
- _this.resetSeekState();
200
- }, 10); // 交互结束 恢复控制栏的隐藏流程
201
-
169
+ }
170
+ util.setTimeout(this, () => {
171
+ this.resetSeekState();
172
+ }, 10);
202
173
  player.focus();
203
174
  });
204
-
205
- _defineProperty(_assertThisInitialized(_this), "onMouseMove", function (e) {
206
- var _assertThisInitialize4 = _assertThisInitialized(_this),
207
- pos = _assertThisInitialize4.pos,
208
- player = _assertThisInitialize4.player,
209
- config = _assertThisInitialize4.config,
210
- _state = _assertThisInitialize4._state;
211
-
212
- if (_this.isMobile) {
213
- e.stopPropagation();
175
+ _defineProperty(this, "onMouseMove", (e) => {
176
+ const {
177
+ pos,
178
+ player,
179
+ config
180
+ } = this;
181
+ if (util.checkTouchSupport()) {
214
182
  e.preventDefault();
215
183
  }
216
-
217
- Util.event(e);
218
-
219
- var _ePos = Util.getEventPos(e, player.zoom);
220
-
221
- var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
222
- var diff = Math.abs(pos.x - x);
223
-
184
+ util.event(e);
185
+ const _ePos = util.getEventPos(e, player.zoom);
186
+ const x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
187
+ const diff = Math.abs(pos.x - x);
224
188
  if (pos.moving && diff < config.miniMoveStep || !pos.moving && diff < config.miniStartStep) {
225
189
  return;
226
190
  }
227
-
228
191
  pos.x = x;
229
-
230
- var ret = _this.computeTime(e);
231
-
232
- if (_state.time < ret.currentTime) {
233
- ret.forward = true;
234
- } else {
235
- ret.forward = false;
236
- }
237
-
238
- _state.time = ret.currentTime;
239
-
240
- if (pos.isDown && !pos.moving) {
241
- pos.moving = true;
242
- config.isPauseMoving && player.pause();
243
-
244
- _this.triggerCallbacks('dragstart', ret);
245
- }
246
-
247
- _this.updateWidth(ret.currentTime, ret.percent, 1);
248
-
249
- _this.triggerCallbacks('dragmove', ret);
192
+ const ret = this.computeTime(e);
193
+ this._mouseMoveHandlerHook(e, ret);
250
194
  });
251
-
252
- _defineProperty(_assertThisInitialized(_this), "onMouseEnter", function (e) {
253
- var _assertThisInitialize5 = _assertThisInitialized(_this),
254
- player = _assertThisInitialize5.player,
255
- pos = _assertThisInitialize5.pos;
256
-
195
+ _defineProperty(this, "onMouseOut", (e) => {
196
+ this.triggerCallbacks("mouseout", null, e);
197
+ });
198
+ _defineProperty(this, "onMouseOver", (e) => {
199
+ this.triggerCallbacks("mouseover", null, e);
200
+ });
201
+ _defineProperty(this, "onMouseEnter", (e) => {
202
+ const {
203
+ player,
204
+ pos
205
+ } = this;
206
+ this.triggerCallbacks("mouseenter", null, e);
257
207
  if (pos.isDown || pos.isEnter || player.isMini || !player.config.allowSeekAfterEnded && player.ended) {
258
208
  return;
259
209
  }
260
-
261
210
  pos.isEnter = true;
262
-
263
- _this.bind('mousemove', _this.onMoveOnly);
264
-
265
- _this.bind('mouseleave', _this.onMouseLeave);
266
-
267
- _this.focus();
211
+ this.bind("mousemove", this.onMoveOnly);
212
+ this.bind("mouseleave", this.onMouseLeave);
213
+ this.focus();
268
214
  });
269
-
270
- _defineProperty(_assertThisInitialized(_this), "onMouseLeave", function (e) {
271
- var _assertThisInitialize6 = _assertThisInitialized(_this),
272
- player = _assertThisInitialize6.player,
273
- pos = _assertThisInitialize6.pos;
274
-
215
+ _defineProperty(this, "onMouseLeave", (e) => {
216
+ this.triggerCallbacks("mouseleave", null, e);
217
+ const {
218
+ player,
219
+ pos
220
+ } = this;
275
221
  pos.isEnter = false;
276
-
277
222
  if (player.isMini) {
278
223
  return;
279
224
  }
280
-
281
- _this.unbind('mousemove', _this.onMoveOnly);
282
-
225
+ this.unbind("mousemove", this.onMoveOnly);
283
226
  if (pos.isDown) {
284
- _this.unbind('mouseleave', _this.onMouseLeave);
285
-
227
+ this.unbind("mouseleave", this.onMouseLeave);
286
228
  return;
287
229
  }
288
-
289
- _this.blur();
230
+ this.blur();
290
231
  });
291
-
292
- _this.useable = false;
293
- /**
294
- * @readonly
295
- */
296
-
297
- _this.isProgressMoving = false;
298
- /**
299
- * @private
300
- */
301
-
302
- _this.__dragCallBacks = [];
303
- /**
304
- * @private
305
- */
306
-
307
- _this._state = {
232
+ this.useable = false;
233
+ this.isProgressMoving = false;
234
+ this.__dragCallBacks = [];
235
+ this._state = {
308
236
  now: -1,
309
237
  direc: 0,
310
238
  time: 0
311
239
  };
312
- return _this;
240
+ this._disableBlur = false;
313
241
  }
314
-
315
- _createClass(Progress, [{
316
- key: "duration",
317
- get: function get() {
318
- return this.playerConfig.customDuration || this.player.duration;
319
- }
320
- }, {
321
- key: "timeOffset",
322
- get: function get() {
323
- return this.playerConfig.timeOffset || 0;
324
- }
325
- }, {
326
- key: "changeState",
327
- value: function changeState() {
328
- var useable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
329
- this.useable = useable;
242
+ get duration() {
243
+ return this.playerConfig.customDuration || this.player.duration;
244
+ }
245
+ get timeOffset() {
246
+ return this.playerConfig.timeOffset || 0;
247
+ }
248
+ changeState(useable = true) {
249
+ this.useable = useable;
250
+ }
251
+ createInner() {
252
+ this.innerList = new InnerList({
253
+ fragments: this.config.fragments,
254
+ style: this.playerConfig.commonStyle || {}
255
+ });
256
+ this.outer.insertBefore(this.innerList.render(), this.outer.children[0]);
257
+ ["findHightLight", "unHightLight", "setHightLight", "findFragment"].map((item) => {
258
+ this[item] = this.innerList[item].bind(this.innerList);
259
+ });
260
+ }
261
+ afterCreate() {
262
+ if (this.config.disable || this.playerConfig.isLive) {
263
+ return;
330
264
  }
331
- /**
332
- * @description 创建内部进度条,并挂载到xg-outer上,
333
- * 并把一些对外API绑定在progress上供外部调用
334
- *
335
- */
336
-
337
- }, {
338
- key: "createInner",
339
- value: function createInner() {
340
- var _this2 = this;
341
-
342
- this.innerList = new InnerList({
343
- fragments: this.config.fragments,
344
- style: this.playerConfig.commonStyle || {}
345
- });
346
- this.outer.insertBefore(this.innerList.render(), this.outer.children[0]);
347
- ['findHightLight', 'unHightLight', 'setHightLight', 'findFragment'].map(function (item) {
348
- _this2[item] = _this2.innerList[item].bind(_this2.innerList);
349
- });
265
+ this.pos = {
266
+ x: 0,
267
+ y: 0,
268
+ moving: false,
269
+ isDown: false,
270
+ isEnter: false
271
+ };
272
+ this.outer = this.find("xg-outer");
273
+ this.createInner();
274
+ if (sniffer.device === "mobile") {
275
+ this.config.isDragingSeek = false;
276
+ this.isMobile = true;
350
277
  }
351
- }, {
352
- key: "afterCreate",
353
- value: function afterCreate() {
354
- var _this3 = this;
355
-
356
- if (this.config.disable || this.playerConfig.isLive) {
357
- return;
358
- }
359
-
360
- this.pos = {
361
- x: 0,
362
- // 水平方向位移
363
- y: 0,
364
- // 垂直方向位移
365
- moving: false,
366
- // 是否正在移动
367
- isDown: false,
368
- // 是否mouseDown
369
- isEnter: false // 是否触发了mouseEnter
370
-
371
- };
372
- this.outer = this.find('xg-outer');
373
- this.createInner();
374
-
375
- if (Sniffer.device === 'mobile') {
376
- this.config.isDragingSeek = false;
377
- this.isMobile = true;
278
+ this.progressBtn = this.find(".xgplayer-progress-btn");
279
+ this.on(DURATION_CHANGE, () => {
280
+ this.onMouseLeave();
281
+ });
282
+ this.on(TIME_UPDATE, () => {
283
+ this.onTimeupdate();
284
+ });
285
+ this.on(SEEKED, () => {
286
+ this.onTimeupdate();
287
+ this.onCacheUpdate();
288
+ });
289
+ this.on(PROGRESS, () => {
290
+ this.onCacheUpdate();
291
+ });
292
+ this.on(ENDED, () => {
293
+ this.onCacheUpdate();
294
+ this._state.now = 0;
295
+ });
296
+ this.on(EMPTIED, () => {
297
+ this.onReset();
298
+ });
299
+ this.bindDomEvents();
300
+ this.initCustomStyle();
301
+ }
302
+ initCustomStyle() {
303
+ const {
304
+ commonStyle
305
+ } = this.playerConfig || {};
306
+ const {
307
+ sliderBtnStyle
308
+ } = commonStyle;
309
+ const {
310
+ progressBtn
311
+ } = this;
312
+ if (sliderBtnStyle) {
313
+ if (typeof sliderBtnStyle === "string") {
314
+ progressBtn.style.boxShadow = sliderBtnStyle;
315
+ } else if (typeof sliderBtnStyle === "object") {
316
+ Object.keys(sliderBtnStyle).map((key) => {
317
+ progressBtn.style[key] = sliderBtnStyle[key];
318
+ });
378
319
  }
379
-
380
- this.progressBtn = this.find('.xgplayer-progress-btn');
381
- this.on(TIME_UPDATE, function () {
382
- _this3.onTimeupdate();
383
- });
384
- this.on(SEEKED, function () {
385
- _this3.onTimeupdate();
386
-
387
- _this3.onCacheUpdate();
388
- });
389
- this.on(PROGRESS, function () {
390
- _this3.onCacheUpdate();
391
- });
392
- this.on(ENDED, function () {
393
- _this3.onCacheUpdate();
394
-
395
- _this3._state.now = 0;
396
- });
397
- this.on(EMPTIED, function () {
398
- _this3.onReset();
399
- });
400
- this.bindDomEvents();
401
- this.initCustomStyle();
402
320
  }
403
- }, {
404
- key: "initCustomStyle",
405
- value: function initCustomStyle() {
406
- var _ref = this.playerConfig || {},
407
- commonStyle = _ref.commonStyle;
408
-
409
- var sliderBtnStyle = commonStyle.sliderBtnStyle;
410
- var progressBtn = this.progressBtn;
411
-
412
- if (sliderBtnStyle) {
413
- if (typeof sliderBtnStyle === 'string') {
414
- progressBtn.style.boxShadow = sliderBtnStyle;
415
- } else if (_typeof(sliderBtnStyle) === 'object') {
416
- Object.keys(sliderBtnStyle).map(function (key) {
417
- progressBtn.style[key] = sliderBtnStyle[key];
418
- });
321
+ }
322
+ triggerCallbacks(type, data, event) {
323
+ if (this.__dragCallBacks.length > 0) {
324
+ this.__dragCallBacks.map((item) => {
325
+ if (item && item.handler && item.type === type) {
326
+ try {
327
+ item.handler(data, event);
328
+ } catch (error) {
329
+ console.error(`[XGPLAYER][triggerCallbacks] ${item} error`, error);
330
+ }
419
331
  }
420
- }
332
+ });
421
333
  }
422
- /**
423
- * 触发某一类回调监听
424
- * @param { string } type 类型 drag/dragend
425
- * @param { any} data 具体数据
426
- */
427
-
428
- }, {
429
- key: "triggerCallbacks",
430
- value: function triggerCallbacks(type, data) {
431
- if (this.__dragCallBacks.length > 0) {
432
- this.__dragCallBacks.map(function (item) {
433
- if (item && item.handler && item.type === type) {
434
- try {
435
- item.handler(data);
436
- } catch (error) {
437
- console.error("[XGPLAYER][triggerCallbacks] ".concat(item, " error"), error);
438
- }
439
- }
440
- });
441
- }
334
+ }
335
+ addCallBack(type, handle) {
336
+ if (handle && typeof handle === "function") {
337
+ this.__dragCallBacks.push({
338
+ type,
339
+ handler: handle
340
+ });
442
341
  }
443
- /**
444
- * 供外部插件添加回调
445
- * @param {string} type 类型 drag/dragend
446
- * @param {function} handle 回调函数句柄
447
- */
448
-
449
- }, {
450
- key: "addCallBack",
451
- value: function addCallBack(type, handle) {
452
- if (handle && typeof handle === 'function') {
453
- this.__dragCallBacks.push({
454
- type: type,
455
- handler: handle
456
- });
342
+ }
343
+ removeCallBack(type, event) {
344
+ const {
345
+ __dragCallBacks
346
+ } = this;
347
+ let _index = -1;
348
+ __dragCallBacks.map((item, index) => {
349
+ if (item && item.type === type && item.handler === event) {
350
+ _index = index;
457
351
  }
352
+ });
353
+ if (_index > -1) {
354
+ __dragCallBacks.splice(_index, 1);
458
355
  }
459
- /**
460
- * 供外部插件移除回调
461
- * @param {string} type 类型 drag/dragend
462
- * @param {Function} event 回调函数句柄
463
- */
464
-
465
- }, {
466
- key: "removeCallBack",
467
- value: function removeCallBack(type, event) {
468
- var __dragCallBacks = this.__dragCallBacks;
469
-
470
- var _index = -1;
471
-
472
- __dragCallBacks.map(function (item, index) {
473
- if (item && item.type === type && item.handler === event) {
474
- _index = index;
475
- }
476
- });
477
-
478
- if (_index > -1) {
479
- __dragCallBacks.splice(_index, 1);
356
+ }
357
+ bindDomEvents() {
358
+ const {
359
+ controls,
360
+ config
361
+ } = this.player;
362
+ this._mouseDownHandlerHook = this.hook("dragstart", this._mouseDownHandler);
363
+ this._mouseUpHandlerHook = this.hook("dragend", this._mouseUpHandler);
364
+ this._mouseMoveHandlerHook = this.hook("drag", this._mouseMoveHandler);
365
+ if (this.domEventType === "touch") {
366
+ this.root.addEventListener("touchstart", this.onMouseDown);
367
+ if (controls) {
368
+ controls.root && controls.root.addEventListener("touchmove", util.stopPropagation);
369
+ controls.center && controls.center.addEventListener("touchend", util.stopPropagation);
480
370
  }
371
+ } else {
372
+ this.bind("mousedown", this.onMouseDown);
373
+ config.isMobileSimulateMode !== "mobile" && this.bind("mouseenter", this.onMouseEnter);
374
+ this.bind("mouseover", this.onMouseOver);
375
+ this.bind("mouseout", this.onMouseOut);
481
376
  }
482
- }, {
483
- key: "bindDomEvents",
484
- value: function bindDomEvents() {
485
- var _this$player = this.player,
486
- controls = _this$player.controls,
487
- config = _this$player.config;
488
-
489
- if (this.isMobile) {
490
- this.bind('touchstart', this.onMouseDown);
491
-
492
- if (controls) {
493
- controls.root && controls.root.addEventListener('touchmove', Util.stopPropagation);
494
- controls.center && controls.center.addEventListener('touchend', Util.stopPropagation);
495
- }
496
- } else {
497
- this.bind('mousedown', this.onMouseDown);
498
- !config.isMobileSimulateMode && this.bind('mouseenter', this.onMouseEnter);
499
- }
377
+ }
378
+ focus() {
379
+ util.addClass(this.root, "active");
380
+ }
381
+ blur() {
382
+ if (this._disableBlur) {
383
+ return;
500
384
  }
501
- }, {
502
- key: "focus",
503
- value: function focus() {
504
- this.player.controls.pauseAutoHide();
505
- Util.addClass(this.root, 'active');
385
+ this.player.controls.recoverAutoHide();
386
+ util.removeClass(this.root, "active");
387
+ }
388
+ disableBlur() {
389
+ this._disableBlur = true;
390
+ }
391
+ enableBlur() {
392
+ this._disableBlur = false;
393
+ }
394
+ updateWidth(currentTime, percent, type) {
395
+ const {
396
+ config,
397
+ player
398
+ } = this;
399
+ if (config.isCloseClickSeek && type === 0) {
400
+ return;
506
401
  }
507
- }, {
508
- key: "blur",
509
- value: function blur() {
510
- this.player.controls.recoverAutoHide();
511
- Util.removeClass(this.root, 'active');
402
+ const realTime = currentTime >= player.duration ? player.duration - config.endedDiff : Number(currentTime).toFixed(1);
403
+ this.updatePercent(percent);
404
+ this.updateTime(currentTime);
405
+ if (type === 1 && (!config.isDragingSeek || player.videoConfig.mediaType === "audio")) {
406
+ return;
512
407
  }
513
- }, {
514
- key: "updateWidth",
515
- value:
516
- /**
517
- * @description 根据currenTime和占用百分比更新进度条
518
- * @param {Number} currentTime 需要更新到的时间
519
- * @param {Number} percent 更新时间占比
520
- * @param {Int} type 触发类型 0-down 1-move 2-up
521
- */
522
- function updateWidth(currentTime, percent, type) {
523
- var config = this.config,
524
- player = this.player;
525
-
526
- if (config.isCloseClickSeek && type === 0) {
527
- return;
528
- }
529
-
530
- var realTime = currentTime > player.duration ? player.duration - 0.2 : Number(currentTime).toFixed(1); // currentTime = currentTime > player.duration ? player.duration - 0.2 : Number(currentTime).toFixed(1)
531
-
532
- this.updatePercent(percent);
533
- this.updateTime(currentTime);
534
-
535
- if (type === 1 && (!config.isDragingSeek || player.videoConfig.mediaType === 'audio')) {
536
- return;
537
- }
538
-
539
- this._state.now = realTime;
540
- this._state.direc = realTime > player.currentTime ? 0 : 1;
541
- player.seek(realTime);
408
+ this._state.now = realTime;
409
+ this._state.direc = realTime > player.currentTime ? 0 : 1;
410
+ player.seek(realTime);
411
+ }
412
+ computeTime(e) {
413
+ const {
414
+ player
415
+ } = this;
416
+ const {
417
+ width,
418
+ height,
419
+ top,
420
+ left
421
+ } = this.root.getBoundingClientRect();
422
+ const _ePos = util.getEventPos(e, player.zoom);
423
+ let rWidth, rLeft, clientX;
424
+ if (player.rotateDeg === 90) {
425
+ rWidth = height;
426
+ rLeft = top;
427
+ clientX = _ePos.clientY;
428
+ } else {
429
+ rWidth = width;
430
+ rLeft = left;
431
+ clientX = _ePos.clientX;
542
432
  }
543
- }, {
544
- key: "computeTime",
545
- value: function computeTime(e) {
546
- var player = this.player;
547
-
548
- var _this$root$getBoundin = this.root.getBoundingClientRect(),
549
- width = _this$root$getBoundin.width,
550
- height = _this$root$getBoundin.height,
551
- top = _this$root$getBoundin.top,
552
- left = _this$root$getBoundin.left;
553
-
554
- var _ePos = Util.getEventPos(e, player.zoom);
555
-
556
- var rWidth, rLeft, clientX;
557
-
558
- if (player.rotateDeg === 90) {
559
- rWidth = height;
560
- rLeft = top;
561
- clientX = _ePos.clientY;
562
- } else {
563
- rWidth = width;
564
- rLeft = left;
565
- clientX = _ePos.clientX;
566
- }
567
-
568
- var offset = clientX - rLeft;
569
- offset = offset > rWidth ? rWidth : offset < 0 ? 0 : offset;
570
- var percent = offset / rWidth;
571
- percent = percent < 0 ? 0 : percent > 1 ? 1 : percent;
572
- var currentTime = parseInt(percent * this.duration * 1000, 10) / 1000;
573
- return {
574
- percent: percent,
575
- currentTime: currentTime,
576
- offset: offset,
577
- width: rWidth,
578
- left: rLeft,
579
- e: e
580
- };
433
+ let offset = clientX - rLeft;
434
+ offset = offset > rWidth ? rWidth : offset < 0 ? 0 : offset;
435
+ let percent = offset / rWidth;
436
+ percent = percent < 0 ? 0 : percent > 1 ? 1 : percent;
437
+ const currentTime = parseInt(percent * this.duration * 1e3, 10) / 1e3;
438
+ return {
439
+ percent,
440
+ currentTime,
441
+ offset,
442
+ width: rWidth,
443
+ left: rLeft,
444
+ e
445
+ };
446
+ }
447
+ updateTime(time) {
448
+ const {
449
+ player,
450
+ duration
451
+ } = this;
452
+ if (time > duration) {
453
+ time = duration;
454
+ } else if (time < 0) {
455
+ time = 0;
581
456
  }
582
- /**
583
- * @description 更新时间插件,在拖拽状态下要接管时间插件的更新状态
584
- * 本位置会和time插件交互
585
- * @param {number} time 根据拖拽距离计算出的时间
586
- */
587
-
588
- }, {
589
- key: "updateTime",
590
- value: function updateTime(time) {
591
- var player = this.player,
592
- duration = this.duration;
593
-
594
- if (time > duration) {
595
- time = duration;
596
- } else if (time < 0) {
597
- time = 0;
598
- }
599
-
600
- var timeIcon = player.plugins.time;
601
-
602
- if (timeIcon) {
603
- timeIcon.updateTime(time);
604
- }
457
+ const timeIcon = player.plugins.time;
458
+ if (timeIcon) {
459
+ timeIcon.updateTime(time);
605
460
  }
606
- /**
607
- * @description 复位正在拖拽状态 ,拖拽的时候要避免timeupdate更新
608
- */
609
-
610
- }, {
611
- key: "resetSeekState",
612
- value: function resetSeekState() {
613
- this.isProgressMoving = false;
614
- var timeIcon = this.player.plugins.time;
615
- timeIcon && timeIcon.resetActive();
461
+ }
462
+ resetSeekState() {
463
+ this.isProgressMoving = false;
464
+ const timeIcon = this.player.plugins.time;
465
+ timeIcon && timeIcon.resetActive();
466
+ }
467
+ updatePercent(percent, notSeek) {
468
+ this.isProgressMoving = true;
469
+ if (this.config.disable) {
470
+ return;
616
471
  }
617
- /**
618
- * @description 拖拽过程中更新UI
619
- * @param {number} percent 小于0的小数
620
- *
621
- */
622
-
623
- }, {
624
- key: "updatePercent",
625
- value: function updatePercent(percent, notSeek) {
626
- this.isProgressMoving = true;
627
-
628
- if (this.config.disable) {
629
- return;
630
- }
631
-
632
- percent = percent > 1 ? 1 : percent < 0 ? 0 : percent;
633
- this.progressBtn.style.left = "".concat(percent * 100, "%");
634
- this.innerList.update({
635
- played: percent * this.duration
636
- }, this.duration);
637
- var miniprogress = this.player.plugins.miniprogress;
638
- miniprogress && miniprogress.update({
639
- played: percent * this.duration
640
- }, this.duration);
472
+ percent = percent > 1 ? 1 : percent < 0 ? 0 : percent;
473
+ this.progressBtn.style.left = `${percent * 100}%`;
474
+ this.innerList.update({
475
+ played: percent * this.duration
476
+ }, this.duration);
477
+ const {
478
+ miniprogress
479
+ } = this.player.plugins;
480
+ miniprogress && miniprogress.update({
481
+ played: percent * this.duration
482
+ }, this.duration);
483
+ }
484
+ onTimeupdate() {
485
+ const {
486
+ player,
487
+ _state,
488
+ duration
489
+ } = this;
490
+ if (player.isSeeking || this.isProgressMoving || player.state < STATES.RUNNING) {
491
+ return;
641
492
  }
642
- /**
643
- * @description 播放进度更新
644
- */
645
-
646
- }, {
647
- key: "onTimeupdate",
648
- value: function onTimeupdate() {
649
- var player = this.player,
650
- _state = this._state,
651
- duration = this.duration;
652
-
653
- if (player.isSeeking || this.isProgressMoving || player.state < STATES.RUNNING) {
493
+ if (_state.now > -1) {
494
+ const abs = parseInt(_state.now * 1e3, 10) - parseInt(player.currentTime * 1e3, 10);
495
+ if (_state.direc === 0 && abs > 300 || _state.direc === 1 && abs > -300) {
496
+ _state.now = -1;
654
497
  return;
655
- }
656
-
657
- if (_state.now > -1) {
658
- var abs = parseInt(_state.now * 1000, 10) - parseInt(player.currentTime * 1000, 10);
659
-
660
- if (_state.direc === 0 && abs > 300 || _state.direc === 1 && abs > -300) {
661
- _state.now = -1;
662
- return;
663
- } else {
664
- _state.now = -1;
665
- }
666
- }
667
-
668
- var time = this.timeOffset + player.currentTime;
669
- this.innerList.update({
670
- played: time
671
- }, duration);
672
- this.progressBtn.style.left = "".concat(time / duration * 100, "%");
673
- var miniprogress = this.player.plugins.miniprogress;
674
- miniprogress && miniprogress.update({
675
- played: time
676
- }, duration);
677
- }
678
- /**
679
- * @description 缓存进度更新
680
- */
681
-
682
- }, {
683
- key: "onCacheUpdate",
684
- value: function onCacheUpdate() {
685
- var player = this.player,
686
- duration = this.duration;
687
- var point = player.bufferedPoint;
688
- this.innerList.update({
689
- cached: point.end
690
- }, duration);
691
- var miniprogress = this.player.plugins.miniprogress;
692
- miniprogress && miniprogress.update({
693
- cached: point.end
694
- }, duration);
695
- }
696
- }, {
697
- key: "onReset",
698
- value: function onReset() {
699
- this.innerList.update({
700
- played: 0,
701
- cached: 0
702
- }, 0);
703
- var miniprogress = this.player.plugins.miniprogress;
704
- miniprogress && miniprogress.update({
705
- cached: 0,
706
- played: 0
707
- }, 0);
708
- }
709
- }, {
710
- key: "destroy",
711
- value: function destroy() {
712
- var player = this.player;
713
- var controls = player.controls;
714
- this.thumbnailPlugin = null;
715
- this.innerList.destroy();
716
- this.innerList = null;
717
-
718
- if (this.isMobile) {
719
- this.unbind('touchstart', this.onMouseDown);
720
- this.unbind('touchmove', this.onMouseMove);
721
- this.unbind('touchend', this.onMouseUp);
722
-
723
- if (controls) {
724
- controls.root && controls.root.removeEventListener('touchmove', Util.stopPropagation);
725
- controls.center && controls.center.removeEventListener('touchend', Util.stopPropagation);
726
- }
727
498
  } else {
728
- this.unbind('mousedown', this.onMouseDown);
729
- this.unbind('mouseenter', this.onMouseEnter);
730
- this.unbind('mousemove', this.onMoveOnly);
731
- document.removeEventListener('mousemove', this.onMouseMove, false);
732
- document.removeEventListener('mouseup', this.onMouseUp, false);
733
- player.root.removeEventListener('click', this.onBodyClick, false);
499
+ _state.now = -1;
734
500
  }
735
501
  }
736
- }, {
737
- key: "render",
738
- value: function render() {
739
- if (this.config.disable || this.playerConfig.isLive) {
740
- return;
502
+ const time = this.timeOffset + player.currentTime;
503
+ this.innerList.update({
504
+ played: time
505
+ }, duration);
506
+ this.progressBtn.style.left = `${time / duration * 100}%`;
507
+ const {
508
+ miniprogress
509
+ } = this.player.plugins;
510
+ miniprogress && miniprogress.update({
511
+ played: time
512
+ }, duration);
513
+ }
514
+ onCacheUpdate() {
515
+ const {
516
+ player,
517
+ duration
518
+ } = this;
519
+ const point = player.bufferedPoint;
520
+ this.innerList.update({
521
+ cached: point.end
522
+ }, duration);
523
+ const {
524
+ miniprogress
525
+ } = this.player.plugins;
526
+ miniprogress && miniprogress.update({
527
+ cached: point.end
528
+ }, duration);
529
+ }
530
+ onReset() {
531
+ this.innerList.update({
532
+ played: 0,
533
+ cached: 0
534
+ }, 0);
535
+ const {
536
+ miniprogress
537
+ } = this.player.plugins;
538
+ miniprogress && miniprogress.update({
539
+ cached: 0,
540
+ played: 0
541
+ }, 0);
542
+ }
543
+ destroy() {
544
+ const {
545
+ player
546
+ } = this;
547
+ const {
548
+ controls
549
+ } = player;
550
+ this.thumbnailPlugin = null;
551
+ this.innerList.destroy();
552
+ this.innerList = null;
553
+ const {
554
+ domEventType
555
+ } = this;
556
+ if (domEventType === "touch") {
557
+ this.root.removeEventListener("touchstart", this.onMouseDown);
558
+ this.root.removeEventListener("touchmove", this.onMouseMove);
559
+ this.root.removeEventListener("touchend", this.onMouseUp);
560
+ if (controls) {
561
+ controls.root && controls.root.removeEventListener("touchmove", util.stopPropagation);
562
+ controls.center && controls.center.removeEventListener("touchend", util.stopPropagation);
741
563
  }
742
-
743
- var controlsMode = this.player.controls ? this.player.controls.config.mode : '';
744
- var className = controlsMode === 'bottom' ? 'xgplayer-progress-bottom' : '';
745
- return "\n <xg-progress class=\"xgplayer-progress ".concat(className, "\">\n <xg-outer class=\"xgplayer-progress-outer\">\n <xg-progress-btn class=\"xgplayer-progress-btn\"></xg-progress-btn>\n </xg-outer>\n </xg-progress>\n ");
564
+ } else {
565
+ this.unbind("mousedown", this.onMouseDown);
566
+ this.unbind("mouseenter", this.onMouseEnter);
567
+ this.unbind("mousemove", this.onMoveOnly);
568
+ this.unbind("mouseleave", this.onMouseLeave);
569
+ document.removeEventListener("mousemove", this.onMouseMove, false);
570
+ document.removeEventListener("mouseup", this.onMouseUp, false);
571
+ player.root.removeEventListener("click", this.onBodyClick, false);
746
572
  }
747
- }], [{
748
- key: "pluginName",
749
- get: function get() {
750
- return 'progress';
751
- }
752
- /**
753
- * @type IProgressConfig
754
- */
755
-
756
- }, {
757
- key: "defaultConfig",
758
- get: function get() {
759
- return {
760
- position: POSITIONS.CONTROLS_CENTER,
761
- index: 0,
762
- disable: false,
763
- isDragingSeek: true,
764
- // 是否在拖拽的过程中更新currentTime
765
- closeMoveSeek: false,
766
- // 是否关闭滑块seek能力
767
- isPauseMoving: false,
768
- // 是否在move的时候暂停视频内容
769
- isCloseClickSeek: false,
770
- // 是否关闭点击进度条的时候seek
771
- fragments: [{
772
- percent: 1
773
- }],
774
- miniMoveStep: 5,
775
- miniStartStep: 2,
776
- onMoveStart: function onMoveStart() {},
777
- // 手势开始移动回调
778
- onMoveEnd: function onMoveEnd() {} // 手势移动结束回调
779
-
780
- };
573
+ }
574
+ render() {
575
+ if (this.config.disable || this.playerConfig.isLive) {
576
+ return;
781
577
  }
782
- }]);
783
-
784
- return Progress;
785
- }(Plugin);
786
-
787
- var Progress$1 = Progress;
788
-
789
- export { Progress$1 as default };
578
+ const controlsMode = this.player.controls ? this.player.controls.config.mode : "";
579
+ const className = controlsMode === "bottom" ? "xgplayer-progress-bottom" : "";
580
+ return `
581
+ <xg-progress class="xgplayer-progress ${className}">
582
+ <xg-outer class="xgplayer-progress-outer">
583
+ <xg-progress-btn class="xgplayer-progress-btn"></xg-progress-btn>
584
+ </xg-outer>
585
+ </xg-progress>
586
+ `;
587
+ }
588
+ }
589
+ export { Progress as default };