xgplayer 3.1.0-alpha.0 → 3.1.0-alpha.2

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 (98) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/index.min.css +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/es/constant.d.ts +0 -4
  6. package/es/constant.js +4 -1
  7. package/es/defaultConfig.js +2 -0
  8. package/es/error.js +2 -2
  9. package/es/index.d.ts +2 -1
  10. package/es/index.js +4 -3
  11. package/es/index.umd.d.ts +60 -1
  12. package/es/index.umd.js +29 -1
  13. package/es/lang/i18n.js +4 -4
  14. package/es/mediaProxy.d.ts +8 -0
  15. package/es/mediaProxy.js +13 -8
  16. package/es/player.d.ts +119 -14
  17. package/es/player.js +669 -163
  18. package/es/plugin/basePlugin.d.ts +6 -3
  19. package/es/plugin/basePlugin.js +6 -5
  20. package/es/plugin/index.d.ts +2 -1
  21. package/es/plugin/plugin.d.ts +0 -1
  22. package/es/plugin/plugin.js +11 -11
  23. package/es/plugin/pluginsManager.d.ts +14 -0
  24. package/es/plugin/pluginsManager.js +32 -16
  25. package/es/plugin/resizeObserver.js +1 -1
  26. package/es/plugins/common/iconPlugin.js +1 -0
  27. package/es/plugins/common/optionList.js +10 -10
  28. package/es/plugins/common/optionsIcon.js +13 -9
  29. package/es/plugins/common/thumbnail.d.ts +0 -1
  30. package/es/plugins/common/thumbnail.js +3 -24
  31. package/es/plugins/controls/index.css +132 -0
  32. package/es/plugins/controls/index.js +189 -0
  33. package/es/plugins/cssFullScreen/index.js +2 -1
  34. package/es/plugins/danmu/danmuIcon.js +1 -0
  35. package/es/plugins/danmu/danmuPanel.js +2 -2
  36. package/es/plugins/danmu/index.js +4 -4
  37. package/es/plugins/definition/index.js +2 -2
  38. package/es/plugins/download/index.js +3 -3
  39. package/es/plugins/dynamicBg/index.js +5 -5
  40. package/es/plugins/enter/index.js +2 -2
  41. package/es/plugins/error/index.js +2 -1
  42. package/es/plugins/fpsDetect/index.js +2 -1
  43. package/es/plugins/fullscreen/backicon.js +3 -3
  44. package/es/plugins/fullscreen/index.js +2 -2
  45. package/es/plugins/gapJump/index.js +2 -1
  46. package/es/plugins/heatmap/index.css +25 -0
  47. package/es/plugins/heatmap/index.d.ts +70 -0
  48. package/es/plugins/heatmap/index.js +306 -0
  49. package/es/plugins/heatmap/index.scss +28 -0
  50. package/es/plugins/keyboard/index.js +3 -3
  51. package/es/plugins/logger/index.js +11 -11
  52. package/es/plugins/miniScreen/index.js +6 -6
  53. package/es/plugins/miniScreen/miniScreenIcon.js +1 -0
  54. package/es/plugins/mobile/index.js +14 -14
  55. package/es/plugins/pc/index.js +3 -3
  56. package/es/plugins/pip/index.d.ts +11 -1
  57. package/es/plugins/pip/index.js +112 -13
  58. package/es/plugins/play/index.js +2 -1
  59. package/es/plugins/playNext/index.js +2 -1
  60. package/es/plugins/playbackRate/index.js +2 -1
  61. package/es/plugins/poster/index.css +4 -0
  62. package/es/plugins/poster/index.js +12 -10
  63. package/es/plugins/poster/index.scss +4 -0
  64. package/es/plugins/progress/index.js +35 -33
  65. package/es/plugins/progress/innerList.js +11 -9
  66. package/es/plugins/progress/miniProgress.js +1 -0
  67. package/es/plugins/progressPreview/dotsApi.js +5 -5
  68. package/es/plugins/progressPreview/index.d.ts +2 -2
  69. package/es/plugins/progressPreview/index.js +29 -29
  70. package/es/plugins/prompt/index.js +5 -5
  71. package/es/plugins/replay/index.js +3 -3
  72. package/es/plugins/rotate/index.js +2 -2
  73. package/es/plugins/screenShot/index.d.ts +1 -0
  74. package/es/plugins/screenShot/index.js +8 -3
  75. package/es/plugins/start/index.js +13 -13
  76. package/es/plugins/stats/index.js +1 -1
  77. package/es/plugins/testspeed/index.js +2 -2
  78. package/es/plugins/time/index.js +34 -31
  79. package/es/plugins/time/timesegments.js +7 -7
  80. package/es/plugins/track/index.js +6 -6
  81. package/es/plugins/volume/index.js +15 -15
  82. package/es/plugins/waitingTimeoutJump/index.js +2 -1
  83. package/es/presets/default-en.d.ts +2 -1
  84. package/es/presets/default-en.js +6 -4
  85. package/es/presets/default.d.ts +3 -2
  86. package/es/presets/default.js +6 -4
  87. package/es/stateClassMap.d.ts +1 -0
  88. package/es/stateClassMap.js +1 -0
  89. package/es/utils/database.js +107 -0
  90. package/es/utils/util.d.ts +300 -282
  91. package/es/utils/util.js +352 -145
  92. package/es/utils/xgplayerTimeRange.d.ts +7 -0
  93. package/es/utils/xgplayerTimeRange.js +25 -0
  94. package/es/version.js +1 -1
  95. package/package.json +3 -10
  96. package/es/simple.umd.d.ts +0 -2
  97. package/es/utils/throttle.d.ts +0 -12
  98. package/es/utils/throttle.js +0 -132
@@ -0,0 +1,306 @@
1
+ import { inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, objectSpread2 as _objectSpread2 } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
+ import util from "../../utils/util.js";
3
+ import { VIDEO_RESIZE, DURATION_CHANGE } from "../../events.js";
4
+ import "../../utils/debug.js";
5
+ import Plugin from "../../plugin/plugin.js";
6
+ var HeatMap = /* @__PURE__ */ function(_Plugin) {
7
+ _inherits(HeatMap2, _Plugin);
8
+ var _super = _createSuper(HeatMap2);
9
+ function HeatMap2(args) {
10
+ var _this;
11
+ _classCallCheck(this, HeatMap2);
12
+ _this = _super.call(this, args);
13
+ _this.canvasHeight = 0;
14
+ _this.canvasWidth = 0;
15
+ _this.width = 0;
16
+ _this.height = 0;
17
+ _this.dataFloatLen = 2;
18
+ _this.xData = [];
19
+ _this.yData = [];
20
+ _this.yMax = 0;
21
+ _this._duration = 0;
22
+ _this.curData = [];
23
+ return _this;
24
+ }
25
+ _createClass(HeatMap2, [{
26
+ key: "afterPlayerInit",
27
+ value: function afterPlayerInit() {
28
+ if (this.root) {
29
+ return;
30
+ }
31
+ this.createRoot();
32
+ this.reset();
33
+ }
34
+ }, {
35
+ key: "afterCreate",
36
+ value: function afterCreate() {
37
+ var _this2 = this;
38
+ this.on(VIDEO_RESIZE, function() {
39
+ _this2.resize();
40
+ });
41
+ this.on(DURATION_CHANGE, function() {
42
+ _this2._duration = _this2.player.duration;
43
+ _this2.reset();
44
+ });
45
+ }
46
+ }, {
47
+ key: "setConfig",
48
+ value: function setConfig(config) {
49
+ var _this3 = this;
50
+ Object.keys(config).forEach(function(key) {
51
+ _this3.config[key] = config[key];
52
+ });
53
+ this.reset();
54
+ }
55
+ }, {
56
+ key: "reset",
57
+ value: function reset() {
58
+ var data = this.config.data;
59
+ this.setData(data);
60
+ this.resize();
61
+ }
62
+ }, {
63
+ key: "createRoot",
64
+ value: function createRoot() {
65
+ if (this.root) {
66
+ return;
67
+ }
68
+ var mode = this.config.mode;
69
+ var progress = this.player.plugins.progress;
70
+ var parent = progress.root;
71
+ var _class = mode === "activeShow" ? "xg-heatmap-active-show" : "xg-heatmap-normal";
72
+ var root = util.createDom("div", "", {}, "xg-heatmap ".concat(_class));
73
+ var c = parent.children.length > 0 ? parent.children[0] : null;
74
+ parent.insertBefore(root, c);
75
+ this.root = root;
76
+ var canvas = util.createDom("canvas", "", {}, "xg-heatmap-canvas");
77
+ this.root.appendChild(canvas);
78
+ this.root.style.height = "".concat(this.config.height, "px");
79
+ this.canvas = canvas;
80
+ }
81
+ }, {
82
+ key: "resize",
83
+ value: function resize() {
84
+ var dpi = this.config.dpi;
85
+ var _this$root$getBoundin = this.root.getBoundingClientRect(), width = _this$root$getBoundin.width, height = _this$root$getBoundin.height;
86
+ if (width === this.width && height * dpi === this.height) {
87
+ return;
88
+ }
89
+ this.width = width;
90
+ this.height = height;
91
+ this.canvas.width = this.canvasWidth = width * dpi;
92
+ this.canvas.height = this.canvasHeight = height * dpi;
93
+ this.yMax = 0;
94
+ if (this.curData.length) {
95
+ this.setData();
96
+ this.drawLinePath();
97
+ }
98
+ }
99
+ }, {
100
+ key: "formatData",
101
+ value: function formatData(data, duration, minValue) {
102
+ var nData = [];
103
+ if (data.length < 1) {
104
+ return nData;
105
+ }
106
+ var totalDur = parseInt(duration * 1e3, 10);
107
+ if (util.typeOf(data[0]) === "Object" && data[0].time !== void 0) {
108
+ if (!totalDur) {
109
+ return nData;
110
+ }
111
+ var step = 1;
112
+ var lastTime = 0;
113
+ data.forEach(function(item) {
114
+ var dur = parseInt(item.time * 1e3, 10);
115
+ if (lastTime && (step < 0 || item.time - lastTime < step)) {
116
+ step = item.time - lastTime;
117
+ }
118
+ lastTime = item.time;
119
+ nData.push(_objectSpread2(_objectSpread2({}, item), {}, {
120
+ percent: dur / totalDur
121
+ }));
122
+ });
123
+ var fTime = nData[0].time;
124
+ if (fTime > 0) {
125
+ var arr = fTime - step > 0 ? [fTime - step, 0] : [0];
126
+ arr.forEach(function(time) {
127
+ var dur = parseInt(time * 1e3, 10);
128
+ nData.unshift({
129
+ time,
130
+ score: minValue,
131
+ percent: dur / totalDur
132
+ });
133
+ });
134
+ }
135
+ var last = nData[nData.length - 1];
136
+ if (duration - last.time > step) {
137
+ [last.time + step, duration].forEach(function(item) {
138
+ var dur = parseInt(item * 1e3, 10);
139
+ nData.push({
140
+ time: item,
141
+ score: minValue,
142
+ percent: dur / totalDur
143
+ });
144
+ });
145
+ }
146
+ } else {
147
+ data.forEach(function(item) {
148
+ nData.push(item);
149
+ });
150
+ }
151
+ return nData;
152
+ }
153
+ }, {
154
+ key: "_getX",
155
+ value: function _getX(index, stepX, item, width) {
156
+ if (item.percent !== void 0) {
157
+ return this.fixFloat(width * item.percent, this.dataFloatLen);
158
+ } else {
159
+ return this.fixFloat((index - 1) * stepX, this.dataFloatLen);
160
+ }
161
+ }
162
+ }, {
163
+ key: "_getY",
164
+ value: function _getY(item, stepY, maxY) {
165
+ var _this$config = this.config, maxValue = _this$config.maxValue, minValue = _this$config.minValue;
166
+ var y = minValue;
167
+ y = item.score !== void 0 ? item.score : item;
168
+ y = Math.min(y, maxValue);
169
+ y = Math.max(y, minValue);
170
+ y = y / stepY;
171
+ y = 1 - y;
172
+ y = this.fixFloat(y * maxY, this.dataFloatLen);
173
+ return y;
174
+ }
175
+ }, {
176
+ key: "setData",
177
+ value: function setData(data) {
178
+ var _this$config2 = this.config, maxValue = _this$config2.maxValue, minValue = _this$config2.minValue, maxLength = _this$config2.maxLength;
179
+ if (data && data.length) {
180
+ this.curData = this.formatData(data, this._duration, minValue);
181
+ }
182
+ data = this.curData;
183
+ if (data.length < 1) {
184
+ return;
185
+ }
186
+ this.xData = [];
187
+ this.yData = [];
188
+ this.yMax = 0;
189
+ var max = maxValue;
190
+ var min = minValue;
191
+ var step_V = max - min;
192
+ var step_Y = this.canvasHeight;
193
+ var curDataLength = data.length;
194
+ var step_D = curDataLength > maxLength ? this.fixFloat(curDataLength / maxLength, this.dataFloatLen) : 1;
195
+ curDataLength = parseInt(curDataLength / step_D);
196
+ var step_X = this.canvasWidth / (curDataLength - 1);
197
+ step_X = this.fixFloat(step_X, this.dataFloatLen);
198
+ if (Number.isNaN(step_X)) {
199
+ return;
200
+ }
201
+ var i = parseInt(this.fixFloat(step_D - 1, 0));
202
+ var j = 0;
203
+ while (j < curDataLength) {
204
+ var x = this._getX(j, step_X, data[i], this.canvasWidth);
205
+ this.xData.push(x);
206
+ var y = this._getY(data[i], step_V, step_Y);
207
+ this.yMax = Math.max(this.yMax, step_Y - y);
208
+ this.yData.push(y);
209
+ j++;
210
+ i = parseInt(this.fixFloat(j * step_D, 0));
211
+ }
212
+ }
213
+ }, {
214
+ key: "_getFillStyle",
215
+ value: function _getFillStyle(ctx) {
216
+ var _this$config3 = this.config, gradient = _this$config3.gradient, gradientColors = _this$config3.gradientColors, fillStyle = _this$config3.fillStyle;
217
+ var fStyle = fillStyle;
218
+ if (gradient && gradient.length === 4) {
219
+ var gradientStyle = ctx.createLinearGradient(gradient[0], gradient[1], gradient[2], gradient[3]);
220
+ if (gradientColors.length < 2) {
221
+ console.warn(this.pluginName, "\u6E10\u53D8\u989C\u8272\u914D\u7F6EgradientColors\u5F02\u5E38");
222
+ } else {
223
+ gradientColors.forEach(function(item) {
224
+ gradientStyle.addColorStop(item.start, item.color);
225
+ });
226
+ fStyle = gradientStyle;
227
+ }
228
+ }
229
+ return fStyle;
230
+ }
231
+ }, {
232
+ key: "drawLinePath",
233
+ value: function drawLinePath() {
234
+ this.clearCanvas();
235
+ var ctx = this.canvas.getContext("2d");
236
+ var xData = this.xData, yData = this.yData;
237
+ var x, y;
238
+ var i = 0;
239
+ var _this$config4 = this.config, lineWidth = _this$config4.lineWidth, alpha = _this$config4.alpha, strokeStyle = _this$config4.strokeStyle;
240
+ var fillStyle = this._getFillStyle(ctx);
241
+ ctx.beginPath();
242
+ ctx.lineWidth = lineWidth;
243
+ ctx.globalAlpha = alpha;
244
+ ctx.strokeStyle = strokeStyle || fillStyle;
245
+ ctx.fillStyle = fillStyle;
246
+ ctx.moveTo(0, this.canvasHeight);
247
+ x = xData[i];
248
+ y = yData[i];
249
+ while (x !== void 0 && y !== void 0) {
250
+ ctx.lineTo(x, y);
251
+ i++;
252
+ x = xData[i];
253
+ y = yData[i];
254
+ }
255
+ ctx.lineTo(this.canvasWidth, this.canvasHeight);
256
+ ctx.closePath();
257
+ ctx.stroke();
258
+ ctx.fill();
259
+ }
260
+ }, {
261
+ key: "clearCanvas",
262
+ value: function clearCanvas() {
263
+ this.canvas.width = this.canvasWidth;
264
+ this.canvas.height = this.canvasHeight;
265
+ }
266
+ }, {
267
+ key: "fixFloat",
268
+ value: function fixFloat(_num, _length) {
269
+ if (typeof _num === "number") {
270
+ return parseFloat(_num.toFixed(_length));
271
+ }
272
+ return NaN;
273
+ }
274
+ }, {
275
+ key: "render",
276
+ value: function render() {
277
+ return "";
278
+ }
279
+ }], [{
280
+ key: "pluginName",
281
+ get: function get() {
282
+ return "heatmap";
283
+ }
284
+ }, {
285
+ key: "defaultConfig",
286
+ get: function get() {
287
+ return {
288
+ lineWidth: 0,
289
+ dpi: 2,
290
+ alpha: 0.7,
291
+ gradient: [],
292
+ gradientColors: [],
293
+ strokeStyle: "",
294
+ fillColor: "#FA1F41",
295
+ height: 20,
296
+ data: [],
297
+ maxValue: 100,
298
+ minValue: 0,
299
+ maxLength: 400,
300
+ mode: "activeShow"
301
+ };
302
+ }
303
+ }]);
304
+ return HeatMap2;
305
+ }(Plugin);
306
+ export { HeatMap as default };
@@ -0,0 +1,28 @@
1
+
2
+ .xg-heatmap {
3
+ position: absolute;
4
+ // background-color: rgb(113, 124, 113);
5
+ height: 40px;
6
+ width: 100%;
7
+ // top: 50%;
8
+ left: 50%;
9
+ transform: translateX(-50%);
10
+ bottom: 10px;
11
+ opacity: 0;
12
+ transition: opacity 0.2s;
13
+ pointer-events: none;
14
+ .xg-heatmap-canvas {
15
+ height: 100%;
16
+ width: 100%;
17
+ }
18
+ &.xg-heatmap-active-show {
19
+ opacity: 0;
20
+ }
21
+ &.xg-heatmap-normal {
22
+ opacity: 1;
23
+ }
24
+ }
25
+
26
+ .xgplayer-progress.active .xg-heatmap-active-show {
27
+ opacity: 1;
28
+ }
@@ -1,5 +1,5 @@
1
1
  import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectSpread2 as _objectSpread2 } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
- import { getCurrentTimeByOffset } from "../../utils/util.js";
2
+ import util from "../../utils/util.js";
3
3
  import { SHORTCUT } from "../../events.js";
4
4
  import BasePlugin from "../../plugin/basePlugin.js";
5
5
  import "delegate";
@@ -242,7 +242,7 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
242
242
  } else {
243
243
  _time = _duration;
244
244
  }
245
- var _seekTime = getCurrentTimeByOffset(_time, timeSegments);
245
+ var _seekTime = util.getCurrentTimeByOffset(_time, timeSegments);
246
246
  var props = {
247
247
  currentTime: {
248
248
  from: currentTime,
@@ -264,7 +264,7 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
264
264
  if (_seekTime < 0) {
265
265
  _seekTime = 0;
266
266
  }
267
- _seekTime = getCurrentTimeByOffset(_seekTime, timeSegments);
267
+ _seekTime = util.getCurrentTimeByOffset(_seekTime, timeSegments);
268
268
  var props = {
269
269
  currentTime: {
270
270
  from: currentTime,
@@ -1,5 +1,5 @@
1
1
  import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectSpread2 as _objectSpread2 } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
- import { clearTimeout, setTimeout, getHostFromUrl } from "../../utils/util.js";
2
+ import util from "../../utils/util.js";
3
3
  import { LOAD_START, LOADED_DATA, SEEKING, SEEKED, DESTROY, URL_CHANGE, PLAYING, CANPLAY, WAITING, ERROR, RESET, AUTOPLAY_STARTED, TIME_UPDATE, XGLOG } from "../../events.js";
4
4
  import XG_DEBUG from "../../utils/debug.js";
5
5
  import Plugin from "../../plugin/plugin.js";
@@ -56,8 +56,8 @@ var XGLogger = /* @__PURE__ */ function(_BasePlugin) {
56
56
  _this.waitingStart = 0;
57
57
  _this.fixedWaitingStart = 0;
58
58
  _this._isWaiting = false;
59
- _this._waitTimer && clearTimeout(_assertThisInitialized(_this), _this._waitTimer);
60
- _this._waittTimer && clearTimeout(_assertThisInitialized(_this), _this._waittTimer);
59
+ _this._waitTimer && util.clearTimeout(_assertThisInitialized(_this), _this._waitTimer);
60
+ _this._waittTimer && util.clearTimeout(_assertThisInitialized(_this), _this._waittTimer);
61
61
  _this._waitTimer = null;
62
62
  _this._waittTimer = null;
63
63
  _this._waitType = 0;
@@ -103,10 +103,10 @@ var XGLogger = /* @__PURE__ */ function(_BasePlugin) {
103
103
  _this._waitType = 0;
104
104
  }
105
105
  _this.fixedWaitingStart = now();
106
- _this._waitTimer = setTimeout(_assertThisInitialized(_this), function() {
106
+ _this._waitTimer = util.setTimeout(_assertThisInitialized(_this), function() {
107
107
  if (_this._isWaiting) {
108
108
  _this.waitingStart = now();
109
- clearTimeout(_assertThisInitialized(_this), _this._waitTimer);
109
+ util.clearTimeout(_assertThisInitialized(_this), _this._waitTimer);
110
110
  _this._waitTimer = null;
111
111
  _this._startWaitTimeout();
112
112
  _this.emitLog(LOG_TYPES.WAIT_START, {
@@ -221,11 +221,11 @@ var XGLogger = /* @__PURE__ */ function(_BasePlugin) {
221
221
  value: function _startWaitTimeout() {
222
222
  var _this3 = this;
223
223
  if (this._waittTimer) {
224
- clearTimeout(this, this._waittTimer);
224
+ util.clearTimeout(this, this._waittTimer);
225
225
  }
226
- this._waittTimer = setTimeout(this, function() {
226
+ this._waittTimer = util.setTimeout(this, function() {
227
227
  _this3.suspendWaitingStatus("timeout");
228
- clearTimeout(_this3, _this3._waittTimer);
228
+ util.clearTimeout(_this3, _this3._waittTimer);
229
229
  _this3._waittTimer = null;
230
230
  }, this.config.waitTimeout);
231
231
  }
@@ -254,11 +254,11 @@ var XGLogger = /* @__PURE__ */ function(_BasePlugin) {
254
254
  key: "suspendWaitingStatus",
255
255
  value: function suspendWaitingStatus(endType) {
256
256
  if (this._waitTimer) {
257
- clearTimeout(this, this._waitTimer);
257
+ util.clearTimeout(this, this._waitTimer);
258
258
  this._waitTimer = null;
259
259
  }
260
260
  if (this._waittTimer) {
261
- clearTimeout(this, this._waittTimer);
261
+ util.clearTimeout(this, this._waittTimer);
262
262
  this._waittTimer = null;
263
263
  }
264
264
  this._isWaiting = false;
@@ -285,7 +285,7 @@ var XGLogger = /* @__PURE__ */ function(_BasePlugin) {
285
285
  var player = this.player;
286
286
  this.emit(XGLOG, _objectSpread2({
287
287
  t: now(),
288
- host: getHostFromUrl(player.currentSrc),
288
+ host: util.getHostFromUrl(player.currentSrc),
289
289
  vtype: player.vtype,
290
290
  eventType,
291
291
  currentTime: this.player.currentTime,
@@ -1,5 +1,5 @@
1
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 { getCss, addClass, removeClass, checkTouchSupport } from "../../utils/util.js";
2
+ import util from "../../utils/util.js";
3
3
  import { PAUSE, PLAY, MINI_STATE_CHANGE } from "../../events.js";
4
4
  import "../../utils/debug.js";
5
5
  import Plugin from "../../plugin/plugin.js";
@@ -28,7 +28,7 @@ var MiniScreen = /* @__PURE__ */ function(_Plugin) {
28
28
  if (!window.scrollY && window.scrollY !== 0 || Math.abs(window.scrollY - _this.pos.scrollY) < 50) {
29
29
  return;
30
30
  }
31
- var scrollHeight = parseInt(getCss(_this.player.root, "height"));
31
+ var scrollHeight = parseInt(util.getCss(_this.player.root, "height"));
32
32
  scrollHeight += _this.config.scrollTop;
33
33
  _this.pos.scrollY = window.scrollY;
34
34
  if (window.scrollY > scrollHeight + 5) {
@@ -88,7 +88,7 @@ var MiniScreen = /* @__PURE__ */ function(_Plugin) {
88
88
  };
89
89
  player.controls.registerPlugin(MiniScreenIcon, options, MiniScreenIcon.pluginName);
90
90
  }
91
- var eventName = checkTouchSupport() ? "touchend" : "click";
91
+ var eventName = util.checkTouchSupport() ? "touchend" : "click";
92
92
  this.bind(".mini-cancel-btn", eventName, this.onCancelClick);
93
93
  this.bind(".play-icon", eventName, this.onCenterClick);
94
94
  if (!this.config.disableDrag) {
@@ -131,7 +131,7 @@ var MiniScreen = /* @__PURE__ */ function(_Plugin) {
131
131
  var player = this.player, playerConfig = this.playerConfig;
132
132
  var target = this.config.target || this.player.root;
133
133
  this.lastStyle = {};
134
- addClass(player.root, "xgplayer-mini");
134
+ util.addClass(player.root, "xgplayer-mini");
135
135
  ["width", "height", "top", "left"].map(function(key) {
136
136
  _this4.lastStyle[key] = target.style[key];
137
137
  target.style[key] = "".concat(_this4.pos[key], "px");
@@ -151,7 +151,7 @@ var MiniScreen = /* @__PURE__ */ function(_Plugin) {
151
151
  }
152
152
  var player = this.player, playerConfig = this.playerConfig;
153
153
  var target = this.config.target || this.player.root;
154
- removeClass(player.root, "xgplayer-mini");
154
+ util.removeClass(player.root, "xgplayer-mini");
155
155
  if (this.lastStyle) {
156
156
  Object.keys(this.lastStyle).map(function(key) {
157
157
  target.style[key] = _this5.lastStyle[key];
@@ -170,7 +170,7 @@ var MiniScreen = /* @__PURE__ */ function(_Plugin) {
170
170
  key: "destroy",
171
171
  value: function destroy() {
172
172
  window.removeEventListener("scroll", this.onScroll);
173
- var eventName = checkTouchSupport() ? "touchend" : "click";
173
+ var eventName = util.checkTouchSupport() ? "touchend" : "click";
174
174
  this.unbind(".mini-cancel-btn", eventName, this.onCancelClick);
175
175
  this.unbind(".play-icon", eventName, this.onCenterClick);
176
176
  this._draggabilly && this._draggabilly.destroy();
@@ -1,4 +1,5 @@
1
1
  import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, createClass as _createClass } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
+ import "../../utils/util.js";
2
3
  import "../../utils/debug.js";
3
4
  import Plugin, { POSITIONS } from "../../plugin/plugin.js";
4
5
  var MiniScreenIcon = /* @__PURE__ */ function(_Plugin) {
@@ -1,6 +1,6 @@
1
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 util from "../../utils/util.js";
2
3
  import sniffer from "../../utils/sniffer.js";
3
- import { checkIsFunction, format, isUndefined, createDom, addClass, createEvent, removeClass } from "../../utils/util.js";
4
4
  import { DURATION_CHANGE, CANPLAY, ENDED } from "../../events.js";
5
5
  import "../../utils/debug.js";
6
6
  import { runHooks } from "../../plugin/hooksDescriptor.js";
@@ -27,8 +27,8 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
27
27
  var touche = _this.getTouche(e);
28
28
  if (touche && !config.disableGesture && _this.duration > 0 && !player.ended) {
29
29
  pos.isStart = true;
30
- checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
31
- _this.find(".xg-dur").innerHTML = format(_this.duration);
30
+ util.checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
31
+ _this.find(".xg-dur").innerHTML = util.format(_this.duration);
32
32
  var rect = _this.root.getBoundingClientRect();
33
33
  if (player.rotateDeg === 90) {
34
34
  pos.top = rect.left;
@@ -104,7 +104,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
104
104
  }
105
105
  pos.scope = -1;
106
106
  _this.resetPos();
107
- checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
107
+ util.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
108
108
  _this.changeAction(ACTIONS.AUTO);
109
109
  });
110
110
  _defineProperty(_assertThisInitialized(_this), "onRootTouchMove", function(e) {
@@ -177,11 +177,11 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
177
177
  config.closedbClick = true;
178
178
  }
179
179
  this.resetPos();
180
- if (!isUndefined(playerConfig.disableGesture)) {
180
+ if (!util.isUndefined(playerConfig.disableGesture)) {
181
181
  config.disableGesture = !!playerConfig.disableGesture;
182
182
  }
183
183
  this.appendChild(".xg-seek-icon", this.icons.seekTipIcon);
184
- this.xgMask = createDom("xg-mask", "", {}, "xgmask");
184
+ this.xgMask = util.createDom("xg-mask", "", {}, "xgmask");
185
185
  player.root.appendChild(this.xgMask);
186
186
  this.initCustomStyle();
187
187
  this.registerThumbnail();
@@ -257,7 +257,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
257
257
  this.find(".xg-bar").style.backgroundColor = progressColor;
258
258
  this.find(".time-preview").style.color = progressColor;
259
259
  }
260
- this.config.disableTimeProgress && addClass(this.find(".xg-timebar"), "hide");
260
+ this.config.disableTimeProgress && util.addClass(this.find(".xg-timebar"), "hide");
261
261
  }
262
262
  }, {
263
263
  key: "resetPos",
@@ -384,7 +384,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
384
384
  var player = this.player, config = this.config, playerConfig = this.playerConfig;
385
385
  if (player.state < STATES.RUNNING) {
386
386
  if (!playerConfig.closeVideoClick) {
387
- this.sendUseAction(createEvent("click"));
387
+ this.sendUseAction(util.createEvent("click"));
388
388
  player.play();
389
389
  }
390
390
  return;
@@ -393,7 +393,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
393
393
  player.isActive ? player.blur() : player.focus();
394
394
  } else if (!playerConfig.closeVideoClick) {
395
395
  if (player.isActive || config.focusVideoClick) {
396
- this.sendUseAction(createEvent("click"));
396
+ this.sendUseAction(util.createEvent("click"));
397
397
  this.switchPlayPause();
398
398
  }
399
399
  player.focus();
@@ -404,7 +404,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
404
404
  value: function dbClickHandler(e) {
405
405
  var config = this.config, player = this.player;
406
406
  if (!config.closedbClick && player.state >= STATES.RUNNING) {
407
- this.sendUseAction(createEvent("dblclick"));
407
+ this.sendUseAction(util.createEvent("dblclick"));
408
408
  this.switchPlayPause();
409
409
  }
410
410
  }
@@ -529,13 +529,13 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
529
529
  this.changeAction(ACTIONS.SEEKING);
530
530
  var startPlugin = player.plugins.start;
531
531
  startPlugin && startPlugin.focusHide();
532
- this.find(".xg-dur").innerHTML = format(this.duration);
533
- this.find(".xg-cur").innerHTML = format(time);
532
+ this.find(".xg-dur").innerHTML = util.format(this.duration);
533
+ this.find(".xg-cur").innerHTML = util.format(time);
534
534
  this.find(".xg-curbar").style.width = "".concat(time / this.duration * 100, "%");
535
535
  if (isForward) {
536
- removeClass(this.find(".xg-seek-show"), "xg-back");
536
+ util.removeClass(this.find(".xg-seek-show"), "xg-back");
537
537
  } else {
538
- addClass(this.find(".xg-seek-show"), "xg-back");
538
+ util.addClass(this.find(".xg-seek-show"), "xg-back");
539
539
  }
540
540
  this.updateThumbnails(time);
541
541
  }
@@ -1,6 +1,6 @@
1
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 "../../utils/util.js";
2
3
  import sniffer from "../../utils/sniffer.js";
3
- import "../../utils/debug.js";
4
4
  import BasePlugin from "../../plugin/basePlugin.js";
5
5
  import "delegate";
6
6
  import { runHooks } from "../../plugin/hooksDescriptor.js";
@@ -132,14 +132,14 @@ var PCPlugin = /* @__PURE__ */ function(_BasePlugin) {
132
132
  key: "initEvents",
133
133
  value: function initEvents() {
134
134
  var _this3 = this;
135
- var _this$player = this.player, video = _this$player.video, root = _this$player.root;
135
+ var _this$player = this.player, media = _this$player.media, root = _this$player.root;
136
136
  var enableContextmenu = this.playerConfig.enableContextmenu;
137
137
  root && root.addEventListener("click", this.onVideoClick, false);
138
138
  root && root.addEventListener("dblclick", this.onVideoDblClick, false);
139
139
  Object.keys(MOUSE_EVENTS).map(function(item) {
140
140
  root.addEventListener(item, _this3[MOUSE_EVENTS[item]], false);
141
141
  });
142
- enableContextmenu && video && video.addEventListener("contextmenu", this.onContextmenu, false);
142
+ !enableContextmenu && media && media.addEventListener("contextmenu", this.onContextmenu, false);
143
143
  }
144
144
  }, {
145
145
  key: "switchPlayPause",
@@ -4,6 +4,11 @@ declare class PIP extends IconPlugin {
4
4
  position: string;
5
5
  index: number;
6
6
  showIcon: boolean;
7
+ preferDocument: boolean;
8
+ width: any;
9
+ height: any;
10
+ docPiPNode: any;
11
+ docPiPStyle: any;
7
12
  };
8
13
  static checkWebkitSetPresentationMode(video: any): boolean;
9
14
  beforeCreate(args: any): void;
@@ -21,17 +26,22 @@ declare class PIP extends IconPlugin {
21
26
  initIcons(): void;
22
27
  initPipEvents(): void;
23
28
  leavePIPCallback: () => void;
24
- enterPIPCallback: (e: any) => void;
25
29
  pipWindow: any;
30
+ enterPIPCallback: (e: any) => void;
26
31
  onWebkitpresentationmodechanged: (e: any) => void;
27
32
  switchPIP: (e: any) => boolean;
33
+ copyStyleIntoPiPWindow(pipWin: any): void;
28
34
  requestPIP(): boolean;
29
35
  /**
30
36
  * 退出画中画
31
37
  */
32
38
  exitPIP(): boolean;
39
+ /**
40
+ * 处于画中画状态
41
+ */
33
42
  get isPip(): boolean;
34
43
  isPIPAvailable(): boolean;
44
+ isDocPIPAvailable(): boolean;
35
45
  render(): string;
36
46
  }
37
47
  import IconPlugin from "../common/iconPlugin";