xgplayer 3.0.0-next.4 → 3.0.0-next.40

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 (252) hide show
  1. package/CHANGELOG.md +183 -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 +199 -0
  6. package/es/constant.d.ts +1 -0
  7. package/es/constant.js +5 -5
  8. package/es/defaultConfig.d.ts +30 -10
  9. package/es/defaultConfig.js +23 -153
  10. package/es/error.d.ts +2 -0
  11. package/es/error.js +54 -105
  12. package/es/events.d.ts +8 -1
  13. package/es/events.js +57 -59
  14. package/es/icons.d.ts +2 -0
  15. package/es/index.css +76 -1714
  16. package/es/index.d.ts +13 -0
  17. package/es/index.js +22 -11
  18. package/es/index.scss +29 -0
  19. package/es/index.umd.d.ts +6 -3
  20. package/es/index.umd.js +20 -46
  21. package/es/lang/en.js +46 -47
  22. package/es/lang/i18n.d.ts +20 -3
  23. package/es/lang/i18n.js +93 -97
  24. package/es/lang/index.d.ts +2 -0
  25. package/es/lang/jp.js +46 -47
  26. package/es/lang/zh-cn.js +46 -47
  27. package/es/lang/zh-hk.js +46 -47
  28. package/es/player.d.ts +209 -84
  29. package/es/player.js +900 -1513
  30. package/es/plugin/basePlugin.d.ts +17 -5
  31. package/es/plugin/basePlugin.js +88 -231
  32. package/es/plugin/hooksDescriptor.d.ts +1 -0
  33. package/es/plugin/hooksDescriptor.js +47 -87
  34. package/es/plugin/plugin.d.ts +8 -2
  35. package/es/plugin/plugin.js +138 -410
  36. package/es/plugin/pluginsManager.d.ts +69 -0
  37. package/es/plugin/pluginsManager.js +161 -205
  38. package/es/plugin/preset.js +10 -28
  39. package/es/plugin/resizeObserver.js +29 -58
  40. package/es/plugins/assets/back.js +4 -0
  41. package/es/plugins/assets/download.js +4 -0
  42. package/es/plugins/assets/exitCssFull.js +4 -0
  43. package/es/plugins/assets/exitFull.js +4 -0
  44. package/es/plugins/assets/loading.js +4 -0
  45. package/es/plugins/assets/panel.js +4 -0
  46. package/es/plugins/assets/pause.js +4 -0
  47. package/es/plugins/assets/pipIcon.js +4 -0
  48. package/es/plugins/assets/pipIconExit.js +4 -0
  49. package/es/plugins/assets/play.js +4 -0
  50. package/es/plugins/assets/playNext.js +4 -0
  51. package/es/plugins/assets/replay.js +4 -0
  52. package/es/plugins/assets/requestCssFull.js +7 -0
  53. package/es/plugins/assets/requestFull.js +4 -0
  54. package/es/plugins/assets/rotate.js +4 -0
  55. package/es/plugins/assets/seekicon.js +4 -0
  56. package/es/plugins/assets/volumeLarge.js +4 -0
  57. package/es/plugins/assets/volumeMuted.js +4 -0
  58. package/es/plugins/assets/volumeSmall.js +4 -0
  59. package/es/plugins/common/iconPlugin.d.ts +5 -0
  60. package/es/plugins/common/iconPlugin.js +57 -0
  61. package/es/plugins/common/index.scss +2 -0
  62. package/es/plugins/common/optionList.js +46 -56
  63. package/es/plugins/common/optionsIcon.css +2 -21
  64. package/es/plugins/common/optionsIcon.d.ts +4 -2
  65. package/es/plugins/common/optionsIcon.js +92 -132
  66. package/es/plugins/common/optionsIcon.scss +121 -0
  67. package/es/plugins/common/thumbnail.d.ts +4 -2
  68. package/es/plugins/common/thumbnail.js +87 -129
  69. package/es/plugins/common/thumbnail.scss +27 -0
  70. package/es/plugins/controls/index.css +4 -10
  71. package/es/plugins/controls/index.d.ts +19 -1
  72. package/es/plugins/controls/index.js +74 -176
  73. package/es/plugins/controls/index.scss +199 -0
  74. package/es/plugins/cssFullScreen/index.d.ts +15 -2
  75. package/es/plugins/cssFullScreen/index.js +62 -64
  76. package/es/plugins/cssFullScreen/index.scss +19 -0
  77. package/es/plugins/danmu/danmuIcon.d.ts +11 -0
  78. package/es/plugins/danmu/danmuIcon.js +44 -46
  79. package/es/plugins/danmu/danmuPanel.d.ts +1 -0
  80. package/es/plugins/danmu/danmuPanel.js +37 -63
  81. package/es/plugins/danmu/index.d.ts +1 -0
  82. package/es/plugins/danmu/index.js +71 -165
  83. package/es/plugins/danmu/index.scss +356 -0
  84. package/es/plugins/definition/index.d.ts +2 -0
  85. package/es/plugins/definition/index.js +72 -171
  86. package/es/plugins/definition/index.scss +4 -0
  87. package/es/plugins/download/index.d.ts +6 -2
  88. package/es/plugins/download/index.js +43 -65
  89. package/es/plugins/download/index.scss +22 -0
  90. package/es/plugins/dynamicBg/index.css +1 -1
  91. package/es/plugins/dynamicBg/index.d.ts +17 -2
  92. package/es/plugins/dynamicBg/index.js +139 -253
  93. package/es/plugins/dynamicBg/index.scss +19 -0
  94. package/es/plugins/enter/index.css +13 -34
  95. package/es/plugins/enter/index.d.ts +1 -0
  96. package/es/plugins/enter/index.js +35 -51
  97. package/es/plugins/enter/index.scss +78 -0
  98. package/es/plugins/error/index.css +0 -1
  99. package/es/plugins/error/index.d.ts +2 -1
  100. package/es/plugins/error/index.js +45 -50
  101. package/es/plugins/error/index.scss +34 -0
  102. package/es/plugins/fullscreen/backicon.d.ts +8 -0
  103. package/es/plugins/fullscreen/backicon.js +34 -38
  104. package/es/plugins/fullscreen/index.css +1 -1
  105. package/es/plugins/fullscreen/index.d.ts +13 -14
  106. package/es/plugins/fullscreen/index.js +70 -212
  107. package/es/plugins/fullscreen/index.scss +35 -0
  108. package/es/plugins/gapJump/index.d.ts +21 -0
  109. package/es/plugins/gapJump/index.js +157 -0
  110. package/es/plugins/keyboard/index.d.ts +1 -0
  111. package/es/plugins/keyboard/index.js +117 -169
  112. package/es/plugins/loading/index.css +2 -32
  113. package/es/plugins/loading/index.d.ts +4 -0
  114. package/es/plugins/loading/index.js +15 -33
  115. package/es/plugins/loading/index.scss +70 -0
  116. package/es/plugins/logger/index.d.ts +26 -10
  117. package/es/plugins/logger/index.js +204 -135
  118. package/es/plugins/miniScreen/index.css +1 -4
  119. package/es/plugins/miniScreen/index.d.ts +12 -0
  120. package/es/plugins/miniScreen/index.js +69 -134
  121. package/es/plugins/miniScreen/index.scss +198 -0
  122. package/es/plugins/miniScreen/miniScreenIcon.d.ts +1 -0
  123. package/es/plugins/miniScreen/miniScreenIcon.js +32 -34
  124. package/es/plugins/mobile/index.css +24 -0
  125. package/es/plugins/mobile/index.d.ts +7 -0
  126. package/es/plugins/mobile/index.js +150 -386
  127. package/es/plugins/mobile/index.scss +180 -0
  128. package/es/plugins/mobile/touch.d.ts +1 -0
  129. package/es/plugins/mobile/touch.js +47 -85
  130. package/es/plugins/netAdaption/index.d.ts +5 -0
  131. package/es/plugins/pc/index.js +74 -124
  132. package/es/plugins/pc/index.scss +5 -0
  133. package/es/plugins/pip/index.d.ts +14 -2
  134. package/es/plugins/pip/index.js +82 -134
  135. package/es/plugins/pip/index.scss +21 -0
  136. package/es/plugins/play/index.d.ts +13 -2
  137. package/es/plugins/play/index.js +55 -60
  138. package/es/plugins/play/index.scss +18 -0
  139. package/es/plugins/playNext/index.d.ts +4 -0
  140. package/es/plugins/playNext/index.js +42 -53
  141. package/es/plugins/playNext/index.scss +35 -0
  142. package/es/plugins/playbackRate/index.d.ts +3 -0
  143. package/es/plugins/playbackRate/index.js +51 -75
  144. package/es/plugins/playbackRate/index.scss +6 -0
  145. package/es/plugins/poster/index.d.ts +3 -0
  146. package/es/plugins/poster/index.js +48 -72
  147. package/es/plugins/poster/index.scss +56 -0
  148. package/es/plugins/progress/index.css +1 -2
  149. package/es/plugins/progress/index.d.ts +16 -2
  150. package/es/plugins/progress/index.js +210 -418
  151. package/es/plugins/progress/index.scss +278 -0
  152. package/es/plugins/progress/innerList.js +72 -87
  153. package/es/plugins/progress/miniProgress.d.ts +1 -0
  154. package/es/plugins/progress/miniProgress.js +36 -40
  155. package/es/plugins/progressPreview/dotsApi.js +71 -119
  156. package/es/plugins/progressPreview/index.css +15 -7
  157. package/es/plugins/progressPreview/index.d.ts +17 -1
  158. package/es/plugins/progressPreview/index.js +285 -189
  159. package/es/plugins/progressPreview/index.scss +226 -0
  160. package/es/plugins/prompt/index.css +0 -1
  161. package/es/plugins/prompt/index.d.ts +3 -0
  162. package/es/plugins/prompt/index.js +54 -71
  163. package/es/plugins/prompt/index.scss +53 -0
  164. package/es/plugins/replay/index.d.ts +5 -0
  165. package/es/plugins/replay/index.js +44 -57
  166. package/es/plugins/replay/index.scss +41 -0
  167. package/es/plugins/rotate/index.d.ts +6 -2
  168. package/es/plugins/rotate/index.js +49 -71
  169. package/es/{style/common/svg-url.css → plugins/rotate/index.scss} +0 -0
  170. package/es/plugins/rotate/index2.js +2 -0
  171. package/es/plugins/screenShot/index.d.ts +7 -2
  172. package/es/plugins/screenShot/index.js +69 -73
  173. package/es/plugins/screenShot/index.scss +5 -0
  174. package/es/plugins/start/index.css +3 -23
  175. package/es/plugins/start/index.d.ts +13 -1
  176. package/es/plugins/start/index.js +90 -142
  177. package/es/plugins/start/index.scss +115 -0
  178. package/es/plugins/stats/index.d.ts +38 -0
  179. package/es/plugins/stats/index.js +215 -0
  180. package/es/plugins/testspeed/index.d.ts +22 -0
  181. package/es/plugins/testspeed/index.js +175 -0
  182. package/es/plugins/time/index.css +0 -1
  183. package/es/plugins/time/index.d.ts +3 -0
  184. package/es/plugins/time/index.js +78 -101
  185. package/es/plugins/time/index.scss +39 -0
  186. package/es/plugins/track/index.css +4 -0
  187. package/es/plugins/track/index.d.ts +24 -3
  188. package/es/plugins/track/index.js +209 -218
  189. package/es/plugins/track/index.scss +22 -0
  190. package/es/plugins/volume/index.css +3 -0
  191. package/es/plugins/volume/index.d.ts +31 -0
  192. package/es/plugins/volume/index.js +175 -203
  193. package/es/plugins/volume/index.scss +124 -0
  194. package/es/plugins/waitingTimeoutJump/index.d.ts +15 -0
  195. package/es/plugins/waitingTimeoutJump/index.js +103 -0
  196. package/es/presets/default-en.d.ts +4 -1
  197. package/es/presets/default-en.js +49 -58
  198. package/es/presets/default.d.ts +5 -77
  199. package/es/presets/default.js +56 -60
  200. package/es/presets/index.d.ts +4 -0
  201. package/es/presets/live.js +28 -38
  202. package/es/presets/mobile.js +32 -38
  203. package/es/proxy.d.ts +50 -9
  204. package/es/proxy.js +250 -469
  205. package/es/state.d.ts +0 -1
  206. package/es/state.js +1 -3
  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 +37 -74
  215. package/es/utils/debug.js +7 -18
  216. package/es/utils/draggabilly.js +69 -194
  217. package/es/utils/sniffer.d.ts +7 -0
  218. package/es/utils/sniffer.js +88 -62
  219. package/es/utils/url.d.ts +1 -0
  220. package/es/utils/util.d.ts +31 -2
  221. package/es/utils/util.js +374 -540
  222. package/es/utils/xgplayerTimeRange.js +6 -12
  223. package/es/version.js +1 -5
  224. package/package.json +12 -21
  225. package/dist/xgplayer.min.css +0 -1
  226. package/dist/xgplayer.mobile.min.css +0 -1
  227. package/es/index.mobile.css +0 -1693
  228. package/es/plugins/assets/back.svg.js +0 -5
  229. package/es/plugins/assets/download.svg.js +0 -5
  230. package/es/plugins/assets/exitCssFull.svg.js +0 -5
  231. package/es/plugins/assets/exitFull.svg.js +0 -5
  232. package/es/plugins/assets/loading.svg.js +0 -5
  233. package/es/plugins/assets/panel.svg.js +0 -5
  234. package/es/plugins/assets/pause.svg.js +0 -5
  235. package/es/plugins/assets/pipIcon.svg.js +0 -5
  236. package/es/plugins/assets/pipIconExit.svg.js +0 -5
  237. package/es/plugins/assets/play.svg.js +0 -5
  238. package/es/plugins/assets/playNext.svg.js +0 -5
  239. package/es/plugins/assets/replay.svg.js +0 -5
  240. package/es/plugins/assets/requestCssFull.svg.js +0 -5
  241. package/es/plugins/assets/requestFull.svg.js +0 -5
  242. package/es/plugins/assets/rotate.svg.js +0 -5
  243. package/es/plugins/assets/seekicon.svg.js +0 -5
  244. package/es/plugins/assets/volumeLarge.svg.js +0 -5
  245. package/es/plugins/assets/volumeMuted.svg.js +0 -5
  246. package/es/plugins/assets/volumeSmall.svg.js +0 -5
  247. package/es/plugins/common/index.css +0 -134
  248. package/es/plugins/common/thumbnail.css +0 -3
  249. package/es/style/common/animation.css +0 -32
  250. package/es/style/common.css +0 -314
  251. package/es/style/index.css +0 -449
  252. package/es/style/variable.css +0 -0
@@ -1,78 +1,91 @@
1
- import 'core-js/modules/es.reflect.construct.js';
2
- import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
3
- import _createClass from '@babel/runtime/helpers/createClass';
4
- import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
5
- import _inherits from '@babel/runtime/helpers/inherits';
6
- import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
7
- import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
8
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
- import 'core-js/modules/es.array.find.js';
10
- import 'core-js/modules/es.array.map.js';
11
- import 'core-js/modules/es.object.keys.js';
12
- import 'core-js/modules/es.array.concat.js';
13
- import Util from '../../utils/util.js';
14
- import Sniffer from '../../utils/sniffer.js';
15
- import Plugin from '../../plugin/plugin.js';
16
- import initDotsAPI from './dotsApi.js';
17
-
18
- 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); }; }
19
-
20
- 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; } }
21
- /**
22
- * @typedef {{
23
- * miniWidth?: number, // 故事点显示最小宽度
24
- * ispots?: Array<{ //故事点列表
25
- * time?: number, // 进度条在此时间戳打点 单位为s
26
- * text?: string, // 打点处的自定义文案
27
- * id?: number | string, // 标记唯一标识,用于删除的时候索引
28
- * duration:? number, // 进度条标识点的时长 默认1s【可选】单位为s
29
- * color?: string, // 进度条标识点的显示颜色【可选】
30
- * style?: { [propName: string]: any }, // 指定样式
31
- * width?: number,
32
- * height?: number
33
- * }>,
34
- * defaultText?: '', // 故事点hover默认文案
35
- * isFocusDots?: true, //
36
- * isShowThumbnail?: true, // 是否显示预览图
37
- * isShowCoverPreview?: false, // 进度条拖动时是否显示播放区域预览图
38
- * mode?: 'short' | 'production', // short // production
39
- * [propName: string]: any
40
- * }} IProgressPreviewConfig
41
- */
42
-
1
+ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
+ import "core-js/modules/es.array.map.js";
3
+ import "core-js/modules/es.object.keys.js";
4
+ import "core-js/modules/es.array.find.js";
5
+ import "core-js/modules/es.object.to-string.js";
6
+ import "core-js/modules/es.number.constructor.js";
7
+ import "core-js/modules/es.array.concat.js";
8
+ import util from "../../utils/util.js";
9
+ import sniffer from "../../utils/sniffer.js";
10
+ import "core-js/modules/web.dom-collections.for-each.js";
11
+ import "core-js/modules/es.array.slice.js";
12
+ import "../../utils/debug.js";
13
+ import Plugin from "../../plugin/plugin.js";
14
+ import "core-js/modules/es.array.iterator.js";
15
+ import "core-js/modules/es.promise.js";
16
+ import "core-js/modules/es.string.iterator.js";
17
+ import "core-js/modules/web.dom-collections.iterator.js";
18
+ import "core-js/modules/es.object.assign.js";
19
+ import "core-js/modules/es.array.splice.js";
20
+ import initDotsAPI from "./dotsApi.js";
43
21
  var CALLBACK_MAP = {
44
- dragmove: 'onProgressMove',
45
- dragstart: 'onProgressDragStart',
46
- dragend: 'onProgressDragEnd'
22
+ dragmove: "onProgressMove",
23
+ dragstart: "onProgressDragStart",
24
+ dragend: "onProgressDragEnd",
25
+ click: "onProgressClick",
26
+ mouseover: "onProgressMouseOver"
47
27
  };
48
- /** */
49
-
50
- var ProgressPreview = /*#__PURE__*/function (_Plugin) {
51
- _inherits(ProgressPreview, _Plugin);
52
-
53
- var _super = _createSuper(ProgressPreview);
54
-
55
- function ProgressPreview(args) {
28
+ var ProgressPreview = /* @__PURE__ */ function(_Plugin) {
29
+ _inherits(ProgressPreview2, _Plugin);
30
+ var _super = _createSuper(ProgressPreview2);
31
+ function ProgressPreview2(args) {
56
32
  var _this;
57
-
58
- _classCallCheck(this, ProgressPreview);
59
-
33
+ _classCallCheck(this, ProgressPreview2);
60
34
  _this = _super.call(this, args);
61
-
62
- _defineProperty(_assertThisInitialized(_this), "onMousemove", function (e) {
63
- if (_this._state.f || Util.hasClass(e.target, 'xg-spot-content')) {
64
- Util.event(e);
35
+ _defineProperty(_assertThisInitialized(_this), "onMousemove", function(e) {
36
+ if (_this.config.disable) {
37
+ return;
38
+ }
39
+ if (_this._state.f || util.hasClass(e.target, "xg-spot-content")) {
40
+ util.event(e);
65
41
  e.stopPropagation();
66
42
  }
67
43
  });
68
-
69
- _defineProperty(_assertThisInitialized(_this), "onMousedown", function (e) {
70
- if (_this._state.f || Util.hasClass(e.target, 'xg-spot-content')) {
71
- Util.event(e);
44
+ _defineProperty(_assertThisInitialized(_this), "onMousedown", function(e) {
45
+ if (_this.config.disable) {
46
+ return;
47
+ }
48
+ if (_this._state.f || util.hasClass(e.target, "xg-spot-content")) {
49
+ util.event(e);
72
50
  e.stopPropagation();
73
51
  }
74
52
  });
75
-
53
+ _defineProperty(_assertThisInitialized(_this), "onMouseup", function(e) {
54
+ if (!_this.isDrag) {
55
+ return;
56
+ }
57
+ var progress = _this.player.plugins.progress;
58
+ if (progress && progress.pos) {
59
+ progress.onMouseUp(e);
60
+ !progress.pos.isEnter && progress.onMouseLeave(e);
61
+ }
62
+ });
63
+ _defineProperty(_assertThisInitialized(_this), "onDotMouseLeave", function(e) {
64
+ if (_this.config.disable) {
65
+ return;
66
+ }
67
+ _this._curDot.removeEventListener("mouseleave", _this.onDotMouseLeave);
68
+ _this.blurDot(e.target);
69
+ _this._curDot = null;
70
+ var progress = _this.player.plugins.progress;
71
+ progress && progress.enableBlur();
72
+ _this.show();
73
+ });
74
+ _defineProperty(_assertThisInitialized(_this), "onProgressMouseOver", function(data, e) {
75
+ if (_this.config.disable) {
76
+ return;
77
+ }
78
+ if (util.hasClass(e.target, "xgplayer-spot") && !_this._curDot) {
79
+ _this._curDot = e.target;
80
+ _this.focusDot(e.target);
81
+ if (_this._curDot.children.length > 0) {
82
+ _this.hide();
83
+ }
84
+ var progress = _this.player.plugins.progress;
85
+ progress && progress.disableBlur();
86
+ _this._curDot.addEventListener("mouseleave", _this.onDotMouseLeave);
87
+ }
88
+ });
76
89
  _this._ispots = [];
77
90
  _this.videoPreview = null;
78
91
  _this.videothumbnail = null;
@@ -83,93 +96,133 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
83
96
  };
84
97
  return _this;
85
98
  }
86
-
87
- _createClass(ProgressPreview, [{
99
+ _createClass(ProgressPreview2, [{
88
100
  key: "beforeCreate",
89
101
  value: function beforeCreate(args) {
90
102
  var progress = args.player.plugins.progress;
91
-
92
103
  if (progress) {
93
104
  args.root = progress.root;
94
105
  }
95
106
  }
107
+ }, {
108
+ key: "afterCreate",
109
+ value: function afterCreate() {
110
+ var _this2 = this;
111
+ this._curDot = null;
112
+ this.handlerSpotClick = this.hook("spotClick", function(event, data) {
113
+ if (data.time) {
114
+ _this2.player.seek(data.time);
115
+ }
116
+ });
117
+ initDotsAPI(this);
118
+ if (this.config.disable) {
119
+ this.disable();
120
+ }
121
+ }
122
+ }, {
123
+ key: "setConfig",
124
+ value: function setConfig(config) {
125
+ var _this3 = this;
126
+ if (!config) {
127
+ return;
128
+ }
129
+ Object.keys(config).map(function(key) {
130
+ _this3.config[key] = config[key];
131
+ });
132
+ }
96
133
  }, {
97
134
  key: "onPluginsReady",
98
135
  value: function onPluginsReady() {
99
136
  var player = this.player;
100
-
101
137
  if (!player.plugins.progress) {
102
138
  return;
103
139
  }
104
-
105
- this.previewLine = this.find('.xg-spot-line');
106
- this.timePoint = this.find('.xgplayer-progress-point');
107
- this.timeText = this.find('.xg-spot-time');
108
- this.tipText = this.find('.spot-inner-text');
140
+ this.previewLine = this.find(".xg-spot-line");
141
+ this.timePoint = this.find(".xgplayer-progress-point");
142
+ this.timeText = this.find(".xg-spot-time");
143
+ this.tipText = this.find(".spot-inner-text");
109
144
  this._hasThumnail = false;
110
145
  this.registerThumbnail();
111
- initDotsAPI(this);
112
146
  this.bindEvents();
113
147
  }
114
148
  }, {
115
149
  key: "bindEvents",
116
150
  value: function bindEvents() {
117
- var _this2 = this;
118
-
151
+ var _this4 = this;
119
152
  var progress = this.player.plugins.progress;
120
-
121
- if (Sniffer.device === 'mobile' || !progress) {
153
+ if (!progress) {
122
154
  return;
123
155
  }
124
-
125
- Object.keys(CALLBACK_MAP).map(function (key) {
126
- _this2[CALLBACK_MAP[key]] = _this2[CALLBACK_MAP[key]].bind(_this2);
127
- progress.addCallBack(key, _this2[CALLBACK_MAP[key]]);
156
+ Object.keys(CALLBACK_MAP).map(function(key) {
157
+ _this4[CALLBACK_MAP[key]] = _this4[CALLBACK_MAP[key]].bind(_this4);
158
+ progress.addCallBack(key, _this4[CALLBACK_MAP[key]]);
128
159
  });
129
- this.bind('.xg-spot-info', 'mousemove', this.onMousemove);
130
- this.bind('.xg-spot-info', 'mousedown', this.onMousedown);
131
- var fun = this.hook('previewClick', function () {// console.log('args', args)
160
+ if (sniffer.device === "mobile")
161
+ return;
162
+ this.bind(".xg-spot-info", "mousemove", this.onMousemove);
163
+ this.bind(".xg-spot-info", "mousedown", this.onMousedown);
164
+ this.bind(".xg-spot-info", "mouseup", this.onMouseup);
165
+ var fun = this.hook("previewClick", function() {
132
166
  });
133
-
134
- this.handlerPreviewClick = function (e) {
167
+ this.handlerPreviewClick = function(e) {
135
168
  e.stopPropagation();
136
- fun(parseInt(_this2._state.now * 1000, 10) / 1000, e);
169
+ fun(parseInt(_this4._state.now * 1e3, 10) / 1e3, e);
137
170
  };
138
-
139
- this.bind('.xg-spot-content', 'mouseup', this.handlerPreviewClick);
171
+ this.bind(".xg-spot-content", "mouseup", this.handlerPreviewClick);
140
172
  }
141
173
  }, {
142
174
  key: "onProgressMove",
143
- value: function onProgressMove(data) {
175
+ value: function onProgressMove(data, e) {
176
+ if (this.config.disable || !this.player.duration) {
177
+ return;
178
+ }
144
179
  this.updatePosition(data.offset, data.width, data.currentTime, data.e);
145
180
  }
146
181
  }, {
147
182
  key: "onProgressDragStart",
148
183
  value: function onProgressDragStart(data) {
184
+ if (this.config.disable || !this.player.duration) {
185
+ return;
186
+ }
149
187
  this.isDrag = true;
150
- this.videoPreview && Util.addClass(this.videoPreview, 'show');
188
+ this.videoPreview && util.addClass(this.videoPreview, "show");
151
189
  }
152
190
  }, {
153
191
  key: "onProgressDragEnd",
154
192
  value: function onProgressDragEnd(data) {
193
+ if (this.config.disable || !this.player.duration) {
194
+ return;
195
+ }
155
196
  this.isDrag = false;
156
- this.videoPreview && Util.removeClass(this.videoPreview, 'show');
197
+ this.videoPreview && util.removeClass(this.videoPreview, "show");
198
+ }
199
+ }, {
200
+ key: "onProgressClick",
201
+ value: function onProgressClick(data, e) {
202
+ if (this.config.disable) {
203
+ return;
204
+ }
205
+ if (util.hasClass(e.target, "xgplayer-spot")) {
206
+ e.stopPropagation();
207
+ e.preventDefault();
208
+ var _data = {};
209
+ ["time", "id", "text"].map(function(key) {
210
+ _data[key] = e.target.getAttribute("data-".concat(key));
211
+ });
212
+ _data.time && (_data.time = Number(_data.time));
213
+ this.handlerSpotClick(e, _data);
214
+ }
157
215
  }
158
216
  }, {
159
217
  key: "updateLinePos",
160
218
  value: function updateLinePos(offset, cwidth) {
161
- var root = this.root,
162
- previewLine = this.previewLine,
163
- timePoint = this.timePoint,
164
- player = this.player;
219
+ var root = this.root, previewLine = this.previewLine, timePoint = this.timePoint, player = this.player;
165
220
  var mode = player.controls.mode;
166
- var isflex = mode === 'flex';
221
+ var isflex = mode === "flex";
167
222
  var lwidth = root.getBoundingClientRect().width;
168
223
  var tWidth = timePoint.getBoundingClientRect().width;
169
224
  var x = offset - lwidth / 2;
170
-
171
225
  var _t, _tt;
172
-
173
226
  if (x < 0 && !isflex) {
174
227
  x = 0;
175
228
  _t = offset - lwidth / 2;
@@ -179,101 +232,112 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
179
232
  !this.thumbnail && (_tt = x - (cwidth - lwidth) - tWidth / 2);
180
233
  x = cwidth - lwidth;
181
234
  } else {
182
- _t = 0;
183
235
  !this.thumbnail && (_tt = -tWidth / 2);
184
236
  }
185
-
186
- _t !== undefined && (previewLine.style.transform = "translateX(".concat(_t, "px)"));
187
- _tt !== undefined && (timePoint.style.transform = "translateX(".concat(_tt, "px)"));
237
+ _t !== void 0 ? previewLine.style.transform = "translateX(".concat(_t, "px)") : previewLine.style.transform = "";
238
+ _tt !== void 0 ? timePoint.style.transform = "translateX(".concat(_tt, "px)") : timePoint.style.transform = "";
188
239
  root.style.transform = "translateX(".concat(x, "px)");
189
240
  }
190
241
  }, {
191
242
  key: "updateTimeText",
192
243
  value: function updateTimeText(timeStr) {
193
- var timeText = this.timeText,
194
- timePoint = this.timePoint;
244
+ var timeText = this.timeText, timePoint = this.timePoint;
195
245
  timeText.textContent = timeStr;
196
246
  !this.thumbnail && (timePoint.textContent = timeStr);
197
247
  }
198
248
  }, {
199
249
  key: "updatePosition",
200
250
  value: function updatePosition(offset, cwidth, time, e) {
201
- var root = this.root,
202
- config = this.config,
203
- _state = this._state;
204
-
251
+ var root = this.root, config = this.config, _state = this._state;
205
252
  if (!root) {
206
253
  return;
207
254
  }
208
-
209
- this.updateLinePos(offset, cwidth); // let now = offset / cwidth * player.duration
210
- // now = now < 0 ? 0 : (now > player.duration ? player.duration : now)
211
-
255
+ this.updateLinePos(offset, cwidth);
212
256
  _state.now = time;
213
- var timeStr = Util.format(time);
214
-
215
- if (e && e.target && Util.hasClass(e.target, 'xgplayer-spot')) {
216
- this.showTips(e.target.getAttribute('data-text'), false, timeStr);
257
+ var timeStr = util.format(time);
258
+ if (e && e.target && util.hasClass(e.target, "xgplayer-spot")) {
259
+ this.showTips(e.target.getAttribute("data-text"), false, timeStr);
260
+ this.focusDot(e.target);
217
261
  _state.f = true;
218
- config.isFocusDots && _state.f && (_state.now = parseInt(e.target.getAttribute('data-time'), 10));
262
+ config.isFocusDots && _state.f && (_state.now = parseInt(e.target.getAttribute("data-time"), 10));
219
263
  } else if (config.defaultText) {
220
264
  _state.f = false;
221
265
  this.showTips(config.defaultText, true, timeStr);
222
266
  } else {
223
267
  _state.f = false;
224
- this.hideTips('');
268
+ this.hideTips("");
225
269
  }
226
-
227
270
  this.updateTimeText(timeStr);
228
271
  this.updateThumbnails(_state.now);
229
272
  }
230
273
  }, {
231
274
  key: "updateThumbnails",
232
275
  value: function updateThumbnails(time) {
233
- var player = this.player,
234
- videoPreview = this.videoPreview;
276
+ var player = this.player, videoPreview = this.videoPreview;
235
277
  var thumbnail = player.plugins.thumbnail;
236
-
237
278
  if (thumbnail && thumbnail.usable) {
238
279
  this.thumbnail && thumbnail.update(this.thumbnail, time, 160, 90);
239
280
  var rect = videoPreview && videoPreview.getBoundingClientRect();
240
281
  this.videothumbnail && thumbnail.update(this.videothumbnail, time, rect.width, rect.height);
241
282
  }
242
283
  }
284
+ }, {
285
+ key: "changeThumbnail",
286
+ value: function changeThumbnail() {
287
+ var thumbnailConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
288
+ if (sniffer.device === "mobile") {
289
+ return;
290
+ }
291
+ var player = this.player, config = this.config;
292
+ var thumbnail = player.getPlugin("thumbnail");
293
+ thumbnail.changeConfig(thumbnailConfig);
294
+ if (!thumbnail || !thumbnail.usable || !config.isShowThumbnail) {
295
+ util.addClass(this.root, "short-line no-thumbnail");
296
+ var tRoot = this.find(".xg-spot-thumbnail");
297
+ this.videoPreview && this.player.root.removeChild(this.videoPreview);
298
+ this.thumbnail && tRoot.removeChild(this.thumbnail);
299
+ this.videothumbnail = null;
300
+ this.thumbnail = null;
301
+ this._hasThumnail = false;
302
+ } else {
303
+ util.removeClass(this.root, "short-line no-thumbnail");
304
+ this._hasThumnail = true;
305
+ var _tRoot = this.find(".xg-spot-thumbnail");
306
+ this.videoPreview && this.player.root.removeChild(this.videoPreview);
307
+ this.thumbnail && _tRoot.removeChild(this.thumbnail);
308
+ this.thumbnail = thumbnail.createThumbnail(_tRoot, "progress-thumbnail");
309
+ if (config.isShowCoverPreview) {
310
+ this.videoPreview = util.createDom("xg-video-preview", "", {}, "xgvideo-preview");
311
+ player.root.appendChild(this.videoPreview);
312
+ this.videothumbnail = thumbnail.createThumbnail(this.videoPreview, "xgvideo-thumbnail");
313
+ }
314
+ }
315
+ }
243
316
  }, {
244
317
  key: "registerThumbnail",
245
318
  value: function registerThumbnail() {
246
- var thumbnailConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
247
-
248
- if (Sniffer.device === 'mobile') {
319
+ var thumbnailConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
320
+ if (sniffer.device === "mobile") {
249
321
  return;
250
322
  }
251
-
252
- var player = this.player,
253
- config = this.config;
254
- var thumbnail = player.getPlugin('thumbnail');
255
-
323
+ var player = this.player, config = this.config;
324
+ var thumbnail = player.getPlugin("thumbnail");
256
325
  if (thumbnail) {
257
- Object.keys(thumbnailConfig).map(function (key) {
258
- thumbnail.config[key] = thumbnailConfig[key];
259
- });
326
+ thumbnail.setConfig(thumbnailConfig);
260
327
  }
261
-
262
328
  if (!thumbnail || !thumbnail.usable || !config.isShowThumbnail) {
263
- Util.addClass(this.root, 'short-line no-thumbnail');
329
+ util.addClass(this.root, "short-line no-thumbnail");
264
330
  return;
265
331
  } else {
266
- Util.removeClass(this.root, 'short-line no-thumbnail');
332
+ util.removeClass(this.root, "short-line no-thumbnail");
267
333
  }
268
-
269
334
  this._hasThumnail = true;
270
- var tRoot = this.find('.xg-spot-thumbnail');
271
- this.thumbnail = thumbnail.createThumbnail(tRoot, 'progress-thumbnail');
272
-
335
+ var tRoot = this.find(".xg-spot-thumbnail");
336
+ this.thumbnail = thumbnail.createThumbnail(tRoot, "progress-thumbnail");
273
337
  if (config.isShowCoverPreview) {
274
- this.videoPreview = Util.createDom('xg-video-preview', '', {}, 'xgvideo-preview');
338
+ this.videoPreview = util.createDom("xg-video-preview", "", {}, "xgvideo-preview");
275
339
  player.root.appendChild(this.videoPreview);
276
- this.videothumbnail = thumbnail.createThumbnail(this.videoPreview, 'xgvideo-thumbnail');
340
+ this.videothumbnail = thumbnail.createThumbnail(this.videoPreview, "xgvideo-thumbnail");
277
341
  }
278
342
  }
279
343
  }, {
@@ -283,11 +347,9 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
283
347
  var player = this.player;
284
348
  var totalWidth = progress.root.getBoundingClientRect().width;
285
349
  var widthPerSeconds = player.duration / totalWidth * 6;
286
-
287
350
  if (time + duration > player.duration) {
288
351
  duration = player.duration - time;
289
352
  }
290
-
291
353
  time / player.duration * 100;
292
354
  duration / player.duration;
293
355
  return {
@@ -300,7 +362,6 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
300
362
  key: "showDot",
301
363
  value: function showDot(id) {
302
364
  var dot = this.findDot(id);
303
-
304
365
  if (dot) {
305
366
  var rect = this.root.getBoundingClientRect();
306
367
  var width = rect.width;
@@ -308,92 +369,127 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
308
369
  this.updatePosition(offset, width, dot.time);
309
370
  }
310
371
  }
372
+ }, {
373
+ key: "focusDot",
374
+ value: function focusDot(target, id) {
375
+ if (!target) {
376
+ return;
377
+ }
378
+ if (!id) {
379
+ id = target.getAttribute("data-id");
380
+ }
381
+ util.addClass(target, "active");
382
+ this._activeDotId = id;
383
+ }
384
+ }, {
385
+ key: "blurDot",
386
+ value: function blurDot(target) {
387
+ if (!target) {
388
+ var id = this._activeDotId;
389
+ target = this.getDotDom(id);
390
+ }
391
+ if (!target) {
392
+ return;
393
+ }
394
+ util.removeClass(target, "active");
395
+ this._activeDotId = null;
396
+ }
311
397
  }, {
312
398
  key: "showTips",
313
399
  value: function showTips(text, isDefault) {
314
- var timeStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
315
-
400
+ var timeStr = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
401
+ util.addClass(this.root, "no-timepoint");
316
402
  if (!text) {
317
403
  return;
318
404
  }
319
-
320
- Util.addClass(this.root, 'no-timepoint');
321
- Util.addClass(this.find('.xg-spot-content'), 'show-text');
322
-
323
- if (isDefault && this.config.mode === 'production') {
324
- Util.addClass(this.root, 'product');
405
+ util.addClass(this.find(".xg-spot-content"), "show-text");
406
+ if (isDefault && this.config.mode === "production") {
407
+ util.addClass(this.root, "product");
325
408
  this.tipText.textContent = text;
326
409
  } else {
327
- Util.removeClass(this.root, 'product');
410
+ util.removeClass(this.root, "product");
328
411
  this.tipText.textContent = this._hasThumnail ? text : "".concat(timeStr, " ").concat(text);
329
412
  }
330
413
  }
331
414
  }, {
332
415
  key: "hideTips",
333
416
  value: function hideTips() {
334
- Util.removeClass(this.root, 'no-timepoint');
335
- this.tipText.textContent = '';
336
- Util.removeClass(this.find('.xg-spot-content'), 'show-text');
337
- Util.removeClass(this.root, 'product');
417
+ util.removeClass(this.root, "no-timepoint");
418
+ this.tipText.textContent = "";
419
+ util.removeClass(this.find(".xg-spot-content"), "show-text");
420
+ util.removeClass(this.root, "product");
421
+ }
422
+ }, {
423
+ key: "hide",
424
+ value: function hide() {
425
+ util.addClass(this.root, "hide");
426
+ }
427
+ }, {
428
+ key: "show",
429
+ value: function show() {
430
+ util.removeClass(this.root, "hide");
431
+ }
432
+ }, {
433
+ key: "enable",
434
+ value: function enable() {
435
+ var config = this.config, playerConfig = this.playerConfig;
436
+ this.config.disable = false;
437
+ this.show();
438
+ if (!this.thumbnail && config.isShowThumbnail) {
439
+ this.registerThumbnail(playerConfig.thumbnail || {});
440
+ }
441
+ }
442
+ }, {
443
+ key: "disable",
444
+ value: function disable() {
445
+ this.config.disable = true;
446
+ this.hide();
338
447
  }
339
448
  }, {
340
449
  key: "destroy",
341
450
  value: function destroy() {
342
- var _this3 = this;
343
-
451
+ var _this5 = this;
344
452
  var progress = this.player.plugins.progress;
345
- progress && Object.keys(CALLBACK_MAP).map(function (key) {
346
- progress.removeCallBack(key, _this3[CALLBACK_MAP[key]]);
453
+ progress && Object.keys(CALLBACK_MAP).map(function(key) {
454
+ progress.removeCallBack(key, _this5[CALLBACK_MAP[key]]);
347
455
  });
348
456
  this.videothumbnail = null;
349
457
  this.thumbnail = null;
350
458
  this.videoPreview && this.player.root.removeChild(this.videoPreview);
351
- this.unbind('.xg-spot-info', 'mousemove', this.onMousemove);
352
- this.unbind('.xg-spot-info', 'mousedown', this.onMousedown);
353
- this.unbind('.xg-spot-content', 'mouseup', this.handlerPreviewClick);
459
+ this.unbind(".xg-spot-info", "mousemove", this.onMousemove);
460
+ this.unbind(".xg-spot-info", "mousedown", this.onMousedown);
461
+ this.unbind(".xg-spot-info", "mouseup", this.onMouseup);
462
+ this.unbind(".xg-spot-content", "mouseup", this.handlerPreviewClick);
354
463
  }
355
464
  }, {
356
465
  key: "render",
357
466
  value: function render() {
358
- if (Sniffer.device === 'mobile' || this.playerConfig.isMobileSimulateMode) {
359
- return '';
467
+ if (sniffer.device === "mobile" || this.playerConfig.isMobileSimulateMode === "mobile") {
468
+ return "";
360
469
  }
361
-
362
- return "<div class=\"xg-spot-info ".concat(this.config.mode === 'short' ? 'short-line' : '', "\">\n <div class=\"xg-spot-content\">\n <div class=\"xg-spot-thumbnail\">\n <span class=\"xg-spot-time\"></span>\n </div>\n <div class=\"xg-spot-text\"><span class=\"spot-inner-text\"></span></div>\n </div>\n <div class=\"xgplayer-progress-point\">00:00</div>\n <div class=\"xg-spot-line\"></div>\n </div>");
470
+ return '<div class="xg-spot-info '.concat(this.config.mode === "short" ? "short-line" : "", '">\n <div class="xg-spot-content">\n <div class="xg-spot-thumbnail">\n <span class="xg-spot-time"></span>\n </div>\n <div class="xg-spot-text"><span class="spot-inner-text"></span></div>\n </div>\n <div class="xgplayer-progress-point">00:00</div>\n <div class="xg-spot-line"></div>\n </div>');
363
471
  }
364
472
  }], [{
365
473
  key: "pluginName",
366
474
  get: function get() {
367
- return 'progresspreview';
475
+ return "progresspreview";
368
476
  }
369
- /**
370
- * @type IProgressPreviewConfig
371
- */
372
-
373
477
  }, {
374
478
  key: "defaultConfig",
375
479
  get: function get() {
376
480
  return {
377
481
  index: 1,
378
482
  miniWidth: 6,
379
- // 故事点显示最小宽度
380
483
  ispots: [],
381
- // 故事点列表
382
- defaultText: '',
383
- // 故事点hover默认文案
484
+ defaultText: "",
384
485
  isFocusDots: true,
385
- //
386
486
  isShowThumbnail: true,
387
- // 是否显示预览图
388
487
  isShowCoverPreview: false,
389
- // 进度条拖动时是否显示播放区域预览图
390
- mode: '' // short // production
391
-
488
+ mode: "",
489
+ disable: false
392
490
  };
393
491
  }
394
492
  }]);
395
-
396
- return ProgressPreview;
493
+ return ProgressPreview2;
397
494
  }(Plugin);
398
-
399
495
  export { ProgressPreview as default };