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.
- package/CHANGELOG.md +11 -1
- package/dist/index.min.css +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/constant.d.ts +0 -4
- package/es/constant.js +4 -1
- package/es/defaultConfig.js +2 -0
- package/es/error.js +2 -2
- package/es/index.d.ts +2 -1
- package/es/index.js +4 -3
- package/es/index.umd.d.ts +60 -1
- package/es/index.umd.js +29 -1
- package/es/lang/i18n.js +4 -4
- package/es/mediaProxy.d.ts +8 -0
- package/es/mediaProxy.js +13 -8
- package/es/player.d.ts +119 -14
- package/es/player.js +669 -163
- package/es/plugin/basePlugin.d.ts +6 -3
- package/es/plugin/basePlugin.js +6 -5
- package/es/plugin/index.d.ts +2 -1
- package/es/plugin/plugin.d.ts +0 -1
- package/es/plugin/plugin.js +11 -11
- package/es/plugin/pluginsManager.d.ts +14 -0
- package/es/plugin/pluginsManager.js +32 -16
- package/es/plugin/resizeObserver.js +1 -1
- package/es/plugins/common/iconPlugin.js +1 -0
- package/es/plugins/common/optionList.js +10 -10
- package/es/plugins/common/optionsIcon.js +13 -9
- package/es/plugins/common/thumbnail.d.ts +0 -1
- package/es/plugins/common/thumbnail.js +3 -24
- package/es/plugins/controls/index.css +132 -0
- package/es/plugins/controls/index.js +189 -0
- package/es/plugins/cssFullScreen/index.js +2 -1
- package/es/plugins/danmu/danmuIcon.js +1 -0
- package/es/plugins/danmu/danmuPanel.js +2 -2
- package/es/plugins/danmu/index.js +4 -4
- package/es/plugins/definition/index.js +2 -2
- package/es/plugins/download/index.js +3 -3
- package/es/plugins/dynamicBg/index.js +5 -5
- package/es/plugins/enter/index.js +2 -2
- package/es/plugins/error/index.js +2 -1
- package/es/plugins/fpsDetect/index.js +2 -1
- package/es/plugins/fullscreen/backicon.js +3 -3
- package/es/plugins/fullscreen/index.js +2 -2
- package/es/plugins/gapJump/index.js +2 -1
- package/es/plugins/heatmap/index.css +25 -0
- package/es/plugins/heatmap/index.d.ts +70 -0
- package/es/plugins/heatmap/index.js +306 -0
- package/es/plugins/heatmap/index.scss +28 -0
- package/es/plugins/keyboard/index.js +3 -3
- package/es/plugins/logger/index.js +11 -11
- package/es/plugins/miniScreen/index.js +6 -6
- package/es/plugins/miniScreen/miniScreenIcon.js +1 -0
- package/es/plugins/mobile/index.js +14 -14
- package/es/plugins/pc/index.js +3 -3
- package/es/plugins/pip/index.d.ts +11 -1
- package/es/plugins/pip/index.js +112 -13
- package/es/plugins/play/index.js +2 -1
- package/es/plugins/playNext/index.js +2 -1
- package/es/plugins/playbackRate/index.js +2 -1
- package/es/plugins/poster/index.css +4 -0
- package/es/plugins/poster/index.js +12 -10
- package/es/plugins/poster/index.scss +4 -0
- package/es/plugins/progress/index.js +35 -33
- package/es/plugins/progress/innerList.js +11 -9
- package/es/plugins/progress/miniProgress.js +1 -0
- package/es/plugins/progressPreview/dotsApi.js +5 -5
- package/es/plugins/progressPreview/index.d.ts +2 -2
- package/es/plugins/progressPreview/index.js +29 -29
- package/es/plugins/prompt/index.js +5 -5
- package/es/plugins/replay/index.js +3 -3
- package/es/plugins/rotate/index.js +2 -2
- package/es/plugins/screenShot/index.d.ts +1 -0
- package/es/plugins/screenShot/index.js +8 -3
- package/es/plugins/start/index.js +13 -13
- package/es/plugins/stats/index.js +1 -1
- package/es/plugins/testspeed/index.js +2 -2
- package/es/plugins/time/index.js +34 -31
- package/es/plugins/time/timesegments.js +7 -7
- package/es/plugins/track/index.js +6 -6
- package/es/plugins/volume/index.js +15 -15
- package/es/plugins/waitingTimeoutJump/index.js +2 -1
- package/es/presets/default-en.d.ts +2 -1
- package/es/presets/default-en.js +6 -4
- package/es/presets/default.d.ts +3 -2
- package/es/presets/default.js +6 -4
- package/es/stateClassMap.d.ts +1 -0
- package/es/stateClassMap.js +1 -0
- package/es/utils/database.js +107 -0
- package/es/utils/util.d.ts +300 -282
- package/es/utils/util.js +352 -145
- package/es/utils/xgplayerTimeRange.d.ts +7 -0
- package/es/utils/xgplayerTimeRange.js +25 -0
- package/es/version.js +1 -1
- package/package.json +3 -10
- package/es/simple.umd.d.ts +0 -2
- package/es/utils/throttle.d.ts +0 -12
- package/es/utils/throttle.js +0 -132
package/es/plugins/pip/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, get as _get, getPrototypeOf as _getPrototypeOf } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
-
import
|
|
1
|
+
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, get as _get, getPrototypeOf as _getPrototypeOf, toConsumableArray as _toConsumableArray } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
+
import util from "../../utils/util.js";
|
|
3
3
|
import { COMPLETE, PIP_CHANGE } from "../../events.js";
|
|
4
4
|
import "../../utils/debug.js";
|
|
5
5
|
import { POSITIONS } from "../../plugin/plugin.js";
|
|
@@ -69,7 +69,7 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
69
69
|
}
|
|
70
70
|
this.once(COMPLETE, function() {
|
|
71
71
|
if (_this2.config.showIcon) {
|
|
72
|
-
removeClass(_this2.find(".xgplayer-icon"), "xg-icon-disable");
|
|
72
|
+
util.removeClass(_this2.find(".xgplayer-icon"), "xg-icon-disable");
|
|
73
73
|
_this2.bind("click", _this2.switchPIP);
|
|
74
74
|
}
|
|
75
75
|
});
|
|
@@ -102,16 +102,19 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
102
102
|
var player = this.player;
|
|
103
103
|
this.leavePIPCallback = function() {
|
|
104
104
|
var paused = player.paused;
|
|
105
|
-
setTimeout(_this3, function() {
|
|
105
|
+
util.setTimeout(_this3, function() {
|
|
106
106
|
!paused && player.mediaPlay();
|
|
107
107
|
}, 0);
|
|
108
108
|
!paused && player.mediaPlay();
|
|
109
109
|
_this3.setAttr("data-state", "normal");
|
|
110
|
+
_this3.pipWindow = null;
|
|
110
111
|
player.emit(PIP_CHANGE, false);
|
|
111
112
|
};
|
|
112
113
|
this.enterPIPCallback = function(e) {
|
|
113
114
|
player.emit(PIP_CHANGE, true);
|
|
114
|
-
|
|
115
|
+
if (e !== null && e !== void 0 && e.pictureInPictureWindow) {
|
|
116
|
+
_this3.pipWindow = e.pictureInPictureWindow;
|
|
117
|
+
}
|
|
115
118
|
_this3.setAttr("data-state", "pip");
|
|
116
119
|
};
|
|
117
120
|
this.onWebkitpresentationmodechanged = function(e) {
|
|
@@ -132,19 +135,97 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
132
135
|
PIP2.checkWebkitSetPresentationMode(player.media) && player.media.addEventListener("webkitpresentationmodechanged", this.onWebkitpresentationmodechanged);
|
|
133
136
|
}
|
|
134
137
|
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "copyStyleIntoPiPWindow",
|
|
140
|
+
value: function copyStyleIntoPiPWindow(pipWin) {
|
|
141
|
+
var textContent = _toConsumableArray(document.styleSheets).map(function(style2) {
|
|
142
|
+
try {
|
|
143
|
+
return _toConsumableArray(style2.cssRules).map(function(rule) {
|
|
144
|
+
return rule.cssText;
|
|
145
|
+
}).join("");
|
|
146
|
+
} catch (e) {
|
|
147
|
+
var link = document.createElement("link");
|
|
148
|
+
link.rel = "stylesheet";
|
|
149
|
+
link.type = style2.type;
|
|
150
|
+
link.media = style2.media;
|
|
151
|
+
link.href = style2.href;
|
|
152
|
+
pipWin.document.head.appendChild(link);
|
|
153
|
+
}
|
|
154
|
+
return "";
|
|
155
|
+
}).filter(Boolean).join("\n");
|
|
156
|
+
var style = document.createElement("style");
|
|
157
|
+
style.textContent = textContent;
|
|
158
|
+
pipWin.document.head.appendChild(style);
|
|
159
|
+
}
|
|
135
160
|
}, {
|
|
136
161
|
key: "requestPIP",
|
|
137
162
|
value: function requestPIP() {
|
|
138
|
-
var
|
|
163
|
+
var _this4 = this;
|
|
164
|
+
var player = this.player, playerConfig = this.playerConfig, config = this.config;
|
|
139
165
|
if (!this.isPIPAvailable() || this.isPip) {
|
|
140
166
|
return;
|
|
141
167
|
}
|
|
142
168
|
try {
|
|
143
169
|
var poster = playerConfig.poster;
|
|
144
170
|
if (poster) {
|
|
145
|
-
player.media.poster = typeOf(poster) === "String" ? poster : poster.poster;
|
|
171
|
+
player.media.poster = util.typeOf(poster) === "String" ? poster : poster.poster;
|
|
172
|
+
}
|
|
173
|
+
if (config.preferDocument && this.isDocPIPAvailable()) {
|
|
174
|
+
var pipOptions = {};
|
|
175
|
+
if (config.width && config.height) {
|
|
176
|
+
pipOptions.width = config.width;
|
|
177
|
+
pipOptions.height = config.height;
|
|
178
|
+
} else {
|
|
179
|
+
var playerRect = player.root.getBoundingClientRect();
|
|
180
|
+
pipOptions.width = playerRect.width;
|
|
181
|
+
pipOptions.height = playerRect.height;
|
|
182
|
+
}
|
|
183
|
+
documentPictureInPicture.requestWindow(pipOptions).then(function(pipWin) {
|
|
184
|
+
var docPiPNode = config.docPiPNode, docPiPStyle = config.docPiPStyle;
|
|
185
|
+
_this4.enterPIPCallback();
|
|
186
|
+
var pipRoot = docPiPNode || player.root;
|
|
187
|
+
var parentNode = pipRoot.parentElement;
|
|
188
|
+
var previousSibling = pipRoot.previousSibling;
|
|
189
|
+
var nextSibling = pipRoot.nextSibling;
|
|
190
|
+
_this4.copyStyleIntoPiPWindow(pipWin);
|
|
191
|
+
var styles = document.createElement("style");
|
|
192
|
+
styles.append("body{padding:0; margin:0;}");
|
|
193
|
+
if (docPiPStyle) {
|
|
194
|
+
var cssContent = "";
|
|
195
|
+
if (typeof docPiPStyle === "string") {
|
|
196
|
+
cssContent = docPiPStyle;
|
|
197
|
+
} else if (typeof docPiPStyle === "function") {
|
|
198
|
+
cssContent = docPiPStyle.call(config);
|
|
199
|
+
}
|
|
200
|
+
if (cssContent) {
|
|
201
|
+
styles.append(cssContent);
|
|
202
|
+
}
|
|
203
|
+
} else if (pipRoot === player.root) {
|
|
204
|
+
styles.append("\n .xgplayer{width: 100%!important; height: 100%!important;}\n ");
|
|
205
|
+
}
|
|
206
|
+
pipWin.document.head.append(styles);
|
|
207
|
+
pipWin.document.body.append(pipRoot);
|
|
208
|
+
pipWin.addEventListener("pagehide", function(event) {
|
|
209
|
+
if (parentNode) {
|
|
210
|
+
if (nextSibling) {
|
|
211
|
+
parentNode.insertBefore(pipRoot, nextSibling);
|
|
212
|
+
} else if (previousSibling) {
|
|
213
|
+
parentNode.insertBefore(pipRoot, previousSibling.nextSibling);
|
|
214
|
+
} else {
|
|
215
|
+
parentNode.appendChild(pipRoot);
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
}
|
|
219
|
+
_this4.leavePIPCallback();
|
|
220
|
+
}, {
|
|
221
|
+
once: true
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
} else if (PIP2.checkWebkitSetPresentationMode(player.media)) {
|
|
225
|
+
player.media.webkitSetPresentationMode("picture-in-picture");
|
|
226
|
+
} else {
|
|
227
|
+
player.media.requestPictureInPicture();
|
|
146
228
|
}
|
|
147
|
-
PIP2.checkWebkitSetPresentationMode(player.media) ? player.media.webkitSetPresentationMode("picture-in-picture") : player.media.requestPictureInPicture();
|
|
148
229
|
return true;
|
|
149
230
|
} catch (reason) {
|
|
150
231
|
console.error("requestPiP", reason);
|
|
@@ -157,7 +238,14 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
157
238
|
var player = this.player;
|
|
158
239
|
try {
|
|
159
240
|
if (this.isPIPAvailable() && this.isPip) {
|
|
160
|
-
|
|
241
|
+
var _documentPictureInPic;
|
|
242
|
+
if (this.isDocPIPAvailable() && (_documentPictureInPic = documentPictureInPicture) !== null && _documentPictureInPic !== void 0 && _documentPictureInPic.window) {
|
|
243
|
+
documentPictureInPicture.window.close();
|
|
244
|
+
} else if (PIP2.checkWebkitSetPresentationMode(player.media)) {
|
|
245
|
+
player.media.webkitSetPresentationMode("inline");
|
|
246
|
+
} else {
|
|
247
|
+
document.exitPictureInPicture();
|
|
248
|
+
}
|
|
161
249
|
}
|
|
162
250
|
return true;
|
|
163
251
|
} catch (reason) {
|
|
@@ -168,15 +256,21 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
168
256
|
}, {
|
|
169
257
|
key: "isPip",
|
|
170
258
|
get: function get() {
|
|
259
|
+
var _documentPictureInPic2;
|
|
171
260
|
var player = this.player;
|
|
172
|
-
return document.pictureInPictureElement && document.pictureInPictureElement === player.media || player.media.webkitPresentationMode === PresentationMode.PIP;
|
|
261
|
+
return !!(this.isDocPIPAvailable() && (_documentPictureInPic2 = documentPictureInPicture) !== null && _documentPictureInPic2 !== void 0 && _documentPictureInPic2.window) || document.pictureInPictureElement && document.pictureInPictureElement === player.media || player.media.webkitPresentationMode === PresentationMode.PIP;
|
|
173
262
|
}
|
|
174
263
|
}, {
|
|
175
264
|
key: "isPIPAvailable",
|
|
176
265
|
value: function isPIPAvailable() {
|
|
177
266
|
var video = this.player.media;
|
|
178
|
-
var _isEnabled = typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : true;
|
|
179
|
-
return _isEnabled && (typeOf(video.disablePictureInPicture) === "Boolean" && !video.disablePictureInPicture || video.webkitSupportsPresentationMode && typeOf(video.webkitSetPresentationMode) === "Function");
|
|
267
|
+
var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : true;
|
|
268
|
+
return _isEnabled && (util.typeOf(video.disablePictureInPicture) === "Boolean" && !video.disablePictureInPicture || video.webkitSupportsPresentationMode && util.typeOf(video.webkitSetPresentationMode) === "Function") || this.isDocPIPAvailable();
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
key: "isDocPIPAvailable",
|
|
272
|
+
value: function isDocPIPAvailable() {
|
|
273
|
+
return "documentPictureInPicture" in window && /^(https|file)/.test(location.protocol);
|
|
180
274
|
}
|
|
181
275
|
}, {
|
|
182
276
|
key: "destroy",
|
|
@@ -208,7 +302,12 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
208
302
|
return {
|
|
209
303
|
position: POSITIONS.CONTROLS_RIGHT,
|
|
210
304
|
index: 6,
|
|
211
|
-
showIcon: false
|
|
305
|
+
showIcon: false,
|
|
306
|
+
preferDocument: false,
|
|
307
|
+
width: void 0,
|
|
308
|
+
height: void 0,
|
|
309
|
+
docPiPNode: void 0,
|
|
310
|
+
docPiPStyle: void 0
|
|
212
311
|
};
|
|
213
312
|
}
|
|
214
313
|
}, {
|
package/es/plugins/play/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, createClass as _createClass, get as _get, getPrototypeOf as _getPrototypeOf } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
-
import "../../utils/
|
|
2
|
+
import "../../utils/util.js";
|
|
3
3
|
import { PAUSE, ERROR, EMPTIED, PLAY } from "../../events.js";
|
|
4
|
+
import "../../utils/debug.js";
|
|
4
5
|
import { POSITIONS } from "../../plugin/plugin.js";
|
|
5
6
|
import { xgIconTips } from "../common/iconTools.js";
|
|
6
7
|
import Icon from "../common/iconPlugin.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
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 { PLAYNEXT } from "../../events.js";
|
|
5
|
+
import "../../utils/debug.js";
|
|
5
6
|
import Plugin, { POSITIONS } from "../../plugin/plugin.js";
|
|
6
7
|
import { xgIconTips } from "../common/iconTools.js";
|
|
7
8
|
import Next from "../assets/playNext.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, createClass as _createClass, objectSpread2 as _objectSpread2, get as _get, getPrototypeOf as _getPrototypeOf } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
-
import "../../utils/
|
|
2
|
+
import "../../utils/util.js";
|
|
3
3
|
import { RATE_CHANGE } from "../../events.js";
|
|
4
|
+
import "../../utils/debug.js";
|
|
4
5
|
import { POSITIONS } from "../../plugin/plugin.js";
|
|
5
6
|
import OptionsIcon from "../common/optionsIcon.js";
|
|
6
7
|
var PlaybackRate = /* @__PURE__ */ function(_OptionsIcon) {
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
opacity: 0;
|
|
23
23
|
visibility: hidden;
|
|
24
24
|
}
|
|
25
|
+
.xgplayer.xgplayer-playing .xg-not-hidden {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
visibility: visible;
|
|
28
|
+
}
|
|
25
29
|
|
|
26
30
|
.xgplayer.xgplayer-is-enter .xgplayer-poster.xg-showplay, .xgplayer.xgplayer-playing .xgplayer-poster.xg-showplay {
|
|
27
31
|
opacity: 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, createClass as _createClass } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
-
import
|
|
2
|
+
import util from "../../utils/util.js";
|
|
3
3
|
import { ENDED, TIME_UPDATE, URL_CHANGE, PLAY } from "../../events.js";
|
|
4
4
|
import "../../utils/debug.js";
|
|
5
5
|
import Plugin from "../../plugin/plugin.js";
|
|
@@ -21,12 +21,12 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
|
|
|
21
21
|
}, {
|
|
22
22
|
key: "hide",
|
|
23
23
|
value: function hide() {
|
|
24
|
-
addClass(this.root, "hide");
|
|
24
|
+
util.addClass(this.root, "hide");
|
|
25
25
|
}
|
|
26
26
|
}, {
|
|
27
27
|
key: "show",
|
|
28
28
|
value: function show() {
|
|
29
|
-
removeClass(this.root, "hide");
|
|
29
|
+
util.removeClass(this.root, "hide");
|
|
30
30
|
}
|
|
31
31
|
}, {
|
|
32
32
|
key: "beforeCreate",
|
|
@@ -41,7 +41,7 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
|
|
|
41
41
|
var _this = this;
|
|
42
42
|
this.on(ENDED, function() {
|
|
43
43
|
if (_this.isEndedShow) {
|
|
44
|
-
removeClass(_this.root, "hide");
|
|
44
|
+
util.removeClass(_this.root, "hide");
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
if (this.config.hideCanplay) {
|
|
@@ -49,15 +49,15 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
|
|
|
49
49
|
_this.onTimeUpdate();
|
|
50
50
|
});
|
|
51
51
|
this.on(URL_CHANGE, function() {
|
|
52
|
-
removeClass(_this.root, "hide");
|
|
53
|
-
addClass(_this.root, "xg-showplay");
|
|
52
|
+
util.removeClass(_this.root, "hide");
|
|
53
|
+
util.addClass(_this.root, "xg-showplay");
|
|
54
54
|
_this.once(TIME_UPDATE, function() {
|
|
55
55
|
_this.onTimeUpdate();
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
} else {
|
|
59
59
|
this.on(PLAY, function() {
|
|
60
|
-
addClass(_this.root, "hide");
|
|
60
|
+
util.addClass(_this.root, "hide");
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -70,7 +70,7 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
|
|
|
70
70
|
_this2.onTimeUpdate();
|
|
71
71
|
});
|
|
72
72
|
} else {
|
|
73
|
-
removeClass(this.root, "xg-showplay");
|
|
73
|
+
util.removeClass(this.root, "xg-showplay");
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}, {
|
|
@@ -104,10 +104,11 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
|
|
|
104
104
|
}, {
|
|
105
105
|
key: "render",
|
|
106
106
|
value: function render() {
|
|
107
|
-
var _this$config = this.config, poster = _this$config.poster, hideCanplay = _this$config.hideCanplay, fillMode = _this$config.fillMode;
|
|
107
|
+
var _this$config = this.config, poster = _this$config.poster, hideCanplay = _this$config.hideCanplay, fillMode = _this$config.fillMode, notHidden = _this$config.notHidden;
|
|
108
108
|
var _bg = this.getBgSize(fillMode);
|
|
109
109
|
var style = poster ? "background-image:url(".concat(poster, ");").concat(_bg) : _bg;
|
|
110
|
-
|
|
110
|
+
var className = notHidden ? "xg-not-hidden" : hideCanplay ? "xg-showplay" : "";
|
|
111
|
+
return '<xg-poster class="xgplayer-poster '.concat(className, '" style="').concat(style, '">\n </xg-poster>');
|
|
111
112
|
}
|
|
112
113
|
}], [{
|
|
113
114
|
key: "pluginName",
|
|
@@ -120,6 +121,7 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
|
|
|
120
121
|
return {
|
|
121
122
|
isEndedShow: true,
|
|
122
123
|
hideCanplay: false,
|
|
124
|
+
notHidden: false,
|
|
123
125
|
poster: "",
|
|
124
126
|
fillMode: "fixWidth"
|
|
125
127
|
};
|
|
@@ -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, objectSpread2 as _objectSpread2, typeof as _typeof } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
+
import util from "../../utils/util.js";
|
|
2
3
|
import sniffer from "../../utils/sniffer.js";
|
|
3
|
-
import { event, getEventPos, checkIsFunction, addClass, removeClass, setTimeout, checkTouchSupport, stopPropagation, getCurrentTimeByOffset, adjustTimeByDuration } from "../../utils/util.js";
|
|
4
4
|
import { DURATION_CHANGE, TIME_UPDATE, SEEKED, PROGRESS, ENDED, EMPTIED, VIDEO_RESIZE } from "../../events.js";
|
|
5
5
|
import "../../utils/debug.js";
|
|
6
6
|
import Plugin, { POSITIONS } from "../../plugin/plugin.js";
|
|
@@ -20,8 +20,8 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
20
20
|
var _assertThisInitialize = _assertThisInitialized(_this), pos = _assertThisInitialize.pos, config = _assertThisInitialize.config, player = _assertThisInitialize.player;
|
|
21
21
|
var ret = data;
|
|
22
22
|
if (e) {
|
|
23
|
-
event(e);
|
|
24
|
-
var _ePos = getEventPos(e, player.zoom);
|
|
23
|
+
util.event(e);
|
|
24
|
+
var _ePos = util.getEventPos(e, player.zoom);
|
|
25
25
|
var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
|
|
26
26
|
if (pos.moving && Math.abs(pos.x - x) < config.miniMoveStep) {
|
|
27
27
|
return;
|
|
@@ -41,7 +41,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
41
41
|
e.preventDefault();
|
|
42
42
|
e.stopPropagation();
|
|
43
43
|
});
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "_mouseDownHandler", function(
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "_mouseDownHandler", function(event, data) {
|
|
45
45
|
_this._state.time = data.currentTime;
|
|
46
46
|
_this.updateWidth(data.currentTime, data.seekTime, data.percent, 0);
|
|
47
47
|
_this._updateInnerFocus(data);
|
|
@@ -70,7 +70,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
70
70
|
});
|
|
71
71
|
_defineProperty(_assertThisInitialized(_this), "onMouseDown", function(e) {
|
|
72
72
|
var _assertThisInitialize4 = _assertThisInitialized(_this), _state = _assertThisInitialize4._state, player = _assertThisInitialize4.player, pos = _assertThisInitialize4.pos, config = _assertThisInitialize4.config, playerConfig = _assertThisInitialize4.playerConfig;
|
|
73
|
-
var _ePos = getEventPos(e, player.zoom);
|
|
73
|
+
var _ePos = util.getEventPos(e, player.zoom);
|
|
74
74
|
var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
|
|
75
75
|
if (player.isMini || config.closeMoveSeek || !playerConfig.allowSeekAfterEnded && player.ended) {
|
|
76
76
|
return;
|
|
@@ -81,9 +81,9 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
81
81
|
}
|
|
82
82
|
e.stopPropagation();
|
|
83
83
|
_this.focus();
|
|
84
|
-
checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
|
|
85
|
-
checkIsFunction(config.onMoveStart) && config.onMoveStart();
|
|
86
|
-
event(e);
|
|
84
|
+
util.checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
|
|
85
|
+
util.checkIsFunction(config.onMoveStart) && config.onMoveStart();
|
|
86
|
+
util.event(e);
|
|
87
87
|
pos.x = x;
|
|
88
88
|
pos.isDown = true;
|
|
89
89
|
pos.moving = false;
|
|
@@ -92,7 +92,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
92
92
|
autoHide: false
|
|
93
93
|
});
|
|
94
94
|
_this.isProgressMoving = true;
|
|
95
|
-
addClass(_this.progressBtn, "active");
|
|
95
|
+
util.addClass(_this.progressBtn, "active");
|
|
96
96
|
var ret = _this.computeTime(e, x);
|
|
97
97
|
ret.prePlayTime = _state.prePlayTime;
|
|
98
98
|
_this._mouseDownHandlerHook(e, ret);
|
|
@@ -111,10 +111,10 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
111
111
|
var _assertThisInitialize5 = _assertThisInitialized(_this), player = _assertThisInitialize5.player, config = _assertThisInitialize5.config, pos = _assertThisInitialize5.pos, playerConfig = _assertThisInitialize5.playerConfig, _state = _assertThisInitialize5._state;
|
|
112
112
|
e.stopPropagation();
|
|
113
113
|
e.preventDefault();
|
|
114
|
-
checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
|
|
115
|
-
checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
|
|
116
|
-
event(e);
|
|
117
|
-
removeClass(_this.progressBtn, "active");
|
|
114
|
+
util.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
|
|
115
|
+
util.checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
|
|
116
|
+
util.event(e);
|
|
117
|
+
util.removeClass(_this.progressBtn, "active");
|
|
118
118
|
var ret = _this.computeTime(e, pos.x);
|
|
119
119
|
ret.prePlayTime = _state.prePlayTime;
|
|
120
120
|
if (pos.moving) {
|
|
@@ -146,18 +146,18 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
146
146
|
playerConfig.isMobileSimulateMode !== "mobile" && _this.bind("mousemove", _this.onMoveOnly);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
setTimeout(_assertThisInitialized(_this), function() {
|
|
149
|
+
util.setTimeout(_assertThisInitialized(_this), function() {
|
|
150
150
|
_this.resetSeekState();
|
|
151
151
|
}, 10);
|
|
152
152
|
player.focus();
|
|
153
153
|
});
|
|
154
154
|
_defineProperty(_assertThisInitialized(_this), "onMouseMove", function(e) {
|
|
155
155
|
var _assertThisInitialize6 = _assertThisInitialized(_this), _state = _assertThisInitialize6._state, pos = _assertThisInitialize6.pos, player = _assertThisInitialize6.player, config = _assertThisInitialize6.config;
|
|
156
|
-
if (checkTouchSupport()) {
|
|
156
|
+
if (util.checkTouchSupport()) {
|
|
157
157
|
e.preventDefault();
|
|
158
158
|
}
|
|
159
|
-
event(e);
|
|
160
|
-
var _ePos = getEventPos(e, player.zoom);
|
|
159
|
+
util.event(e);
|
|
160
|
+
var _ePos = util.getEventPos(e, player.zoom);
|
|
161
161
|
var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
|
|
162
162
|
var diff = Math.abs(pos.x - x);
|
|
163
163
|
if (pos.moving && diff < config.miniMoveStep || !pos.moving && diff < config.miniStartStep) {
|
|
@@ -182,8 +182,8 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
182
182
|
pos.isEnter = true;
|
|
183
183
|
_this.bind("mousemove", _this.onMoveOnly);
|
|
184
184
|
_this.bind("mouseleave", _this.onMouseLeave);
|
|
185
|
-
event(e);
|
|
186
|
-
var _ePos = getEventPos(e, player.zoom);
|
|
185
|
+
util.event(e);
|
|
186
|
+
var _ePos = util.getEventPos(e, player.zoom);
|
|
187
187
|
var x = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
|
|
188
188
|
var ret = _this.computeTime(e, x);
|
|
189
189
|
_this.triggerCallbacks("mouseenter", ret, e);
|
|
@@ -366,12 +366,12 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
366
366
|
}
|
|
367
367
|
}, {
|
|
368
368
|
key: "triggerCallbacks",
|
|
369
|
-
value: function triggerCallbacks(type, data,
|
|
369
|
+
value: function triggerCallbacks(type, data, event) {
|
|
370
370
|
if (this.__dragCallBacks.length > 0) {
|
|
371
371
|
this.__dragCallBacks.map(function(item) {
|
|
372
372
|
if (item && item.handler && item.type === type) {
|
|
373
373
|
try {
|
|
374
|
-
item.handler(data,
|
|
374
|
+
item.handler(data, event);
|
|
375
375
|
} catch (error) {
|
|
376
376
|
console.error("[XGPLAYER][triggerCallbacks] ".concat(item, " error"), error);
|
|
377
377
|
}
|
|
@@ -391,11 +391,11 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
391
391
|
}
|
|
392
392
|
}, {
|
|
393
393
|
key: "removeCallBack",
|
|
394
|
-
value: function removeCallBack(type,
|
|
394
|
+
value: function removeCallBack(type, event) {
|
|
395
395
|
var __dragCallBacks = this.__dragCallBacks;
|
|
396
396
|
var _index = -1;
|
|
397
397
|
__dragCallBacks.map(function(item, index) {
|
|
398
|
-
if (item && item.type === type && item.handler ===
|
|
398
|
+
if (item && item.type === type && item.handler === event) {
|
|
399
399
|
_index = index;
|
|
400
400
|
}
|
|
401
401
|
});
|
|
@@ -428,8 +428,8 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
428
428
|
if (this.domEventType === "touch" || this.domEventType === "compatible") {
|
|
429
429
|
this.root.addEventListener("touchstart", this.onMouseDown);
|
|
430
430
|
if (controls) {
|
|
431
|
-
controls.root && controls.root.addEventListener("touchmove", stopPropagation);
|
|
432
|
-
controls.center && controls.center.addEventListener("touchend", stopPropagation);
|
|
431
|
+
controls.root && controls.root.addEventListener("touchmove", util.stopPropagation);
|
|
432
|
+
controls.center && controls.center.addEventListener("touchend", util.stopPropagation);
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
if (this.domEventType === "mouse" || this.domEventType === "compatible") {
|
|
@@ -444,7 +444,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
444
444
|
key: "focus",
|
|
445
445
|
value: function focus() {
|
|
446
446
|
this.player.controls.pauseAutoHide();
|
|
447
|
-
addClass(this.root, "active");
|
|
447
|
+
util.addClass(this.root, "active");
|
|
448
448
|
}
|
|
449
449
|
}, {
|
|
450
450
|
key: "blur",
|
|
@@ -453,7 +453,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
453
453
|
return;
|
|
454
454
|
}
|
|
455
455
|
this.player.controls.recoverAutoHide();
|
|
456
|
-
removeClass(this.root, "active");
|
|
456
|
+
util.removeClass(this.root, "active");
|
|
457
457
|
}
|
|
458
458
|
}, {
|
|
459
459
|
key: "disableBlur",
|
|
@@ -501,7 +501,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
501
501
|
var percent = offset / rWidth;
|
|
502
502
|
percent = percent < 0 ? 0 : percent > 1 ? 1 : percent;
|
|
503
503
|
var currentTime = parseInt(percent * this.offsetDuration * 1e3, 10) / 1e3;
|
|
504
|
-
var seekTime = getCurrentTimeByOffset(currentTime, player.timeSegments);
|
|
504
|
+
var seekTime = util.getCurrentTimeByOffset(currentTime, player.timeSegments);
|
|
505
505
|
return {
|
|
506
506
|
percent,
|
|
507
507
|
currentTime,
|
|
@@ -554,7 +554,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
554
554
|
key: "onTimeupdate",
|
|
555
555
|
value: function onTimeupdate(isEnded) {
|
|
556
556
|
var player = this.player, _state = this._state, offsetDuration = this.offsetDuration;
|
|
557
|
-
if (player.isSeeking || this.isProgressMoving) {
|
|
557
|
+
if (player.isSeeking && player.media.seeking || this.isProgressMoving || !player.hasStart) {
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
560
560
|
if (_state.now > -1) {
|
|
@@ -567,7 +567,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
var time = this.currentTime;
|
|
570
|
-
time = adjustTimeByDuration(time, offsetDuration, isEnded);
|
|
570
|
+
time = util.adjustTimeByDuration(time, offsetDuration, isEnded);
|
|
571
571
|
this.innerList.update({
|
|
572
572
|
played: time
|
|
573
573
|
}, offsetDuration);
|
|
@@ -585,7 +585,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
585
585
|
return;
|
|
586
586
|
}
|
|
587
587
|
var _end = player.bufferedPoint.end;
|
|
588
|
-
_end = adjustTimeByDuration(_end, duration, isEnded);
|
|
588
|
+
_end = util.adjustTimeByDuration(_end, duration, isEnded);
|
|
589
589
|
this.innerList.update({
|
|
590
590
|
cached: _end
|
|
591
591
|
}, duration);
|
|
@@ -601,11 +601,13 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
601
601
|
played: 0,
|
|
602
602
|
cached: 0
|
|
603
603
|
}, 0);
|
|
604
|
+
this.progressBtn.style.left = "0%";
|
|
604
605
|
var miniprogress = this.player.plugins.miniprogress;
|
|
605
606
|
miniprogress && miniprogress.update({
|
|
606
607
|
cached: 0,
|
|
607
608
|
played: 0
|
|
608
609
|
}, 0);
|
|
610
|
+
this.progressBtn.style.left = "0%";
|
|
609
611
|
}
|
|
610
612
|
}, {
|
|
611
613
|
key: "destroy",
|
|
@@ -621,8 +623,8 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
621
623
|
this.root.removeEventListener("touchmove", this.onMouseMove);
|
|
622
624
|
this.root.removeEventListener("touchend", this.onMouseUp);
|
|
623
625
|
if (controls) {
|
|
624
|
-
controls.root && controls.root.removeEventListener("touchmove", stopPropagation);
|
|
625
|
-
controls.center && controls.center.removeEventListener("touchend", stopPropagation);
|
|
626
|
+
controls.root && controls.root.removeEventListener("touchmove", util.stopPropagation);
|
|
627
|
+
controls.center && controls.center.removeEventListener("touchend", util.stopPropagation);
|
|
626
628
|
}
|
|
627
629
|
}
|
|
628
630
|
if (domEventType === "mouse" || domEventType === "compatible") {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createClass as _createClass, classCallCheck as _classCallCheck } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
-
import
|
|
2
|
+
import util from "../../utils/util.js";
|
|
3
|
+
import "../../utils/debug.js";
|
|
4
|
+
import "delegate";
|
|
3
5
|
var TPL = [{
|
|
4
6
|
tag: "xg-cache",
|
|
5
7
|
className: "xgplayer-progress-cache",
|
|
@@ -123,7 +125,7 @@ var InnerList = /* @__PURE__ */ function() {
|
|
|
123
125
|
this.updateDuration(parseInt(duration * 1e3, 10));
|
|
124
126
|
}
|
|
125
127
|
var playedIndex = this.playedIndex, cachedIndex = this.cachedIndex;
|
|
126
|
-
if (typeOf(data.played) !== "Undefined") {
|
|
128
|
+
if (util.typeOf(data.played) !== "Undefined") {
|
|
127
129
|
var newPIndex = this.findIndex(data.played * 1e3, playedIndex);
|
|
128
130
|
if (newPIndex < 0) {
|
|
129
131
|
return;
|
|
@@ -135,7 +137,7 @@ var InnerList = /* @__PURE__ */ function() {
|
|
|
135
137
|
});
|
|
136
138
|
this.playedIndex = newPIndex;
|
|
137
139
|
}
|
|
138
|
-
if (typeOf(data.cached) !== "Undefined") {
|
|
140
|
+
if (util.typeOf(data.cached) !== "Undefined") {
|
|
139
141
|
var newCIndex = this.findIndex(data.cached * 1e3, cachedIndex);
|
|
140
142
|
if (newCIndex < 0) {
|
|
141
143
|
return;
|
|
@@ -177,7 +179,7 @@ var InnerList = /* @__PURE__ */ function() {
|
|
|
177
179
|
value: function findHightLight() {
|
|
178
180
|
var children = this.root.children;
|
|
179
181
|
for (var i = 0; i < children.length; i++) {
|
|
180
|
-
if (hasClass(children[i], this.fragConfig.fragFocusClass)) {
|
|
182
|
+
if (util.hasClass(children[i], this.fragConfig.fragFocusClass)) {
|
|
181
183
|
return {
|
|
182
184
|
dom: children[i],
|
|
183
185
|
pos: children[i].getBoundingClientRect()
|
|
@@ -202,7 +204,7 @@ var InnerList = /* @__PURE__ */ function() {
|
|
|
202
204
|
value: function unHightLight() {
|
|
203
205
|
var children = this.root.children;
|
|
204
206
|
for (var i = 0; i < children.length; i++) {
|
|
205
|
-
removeClass(children[i], this.fragConfig.fragFocusClass);
|
|
207
|
+
util.removeClass(children[i], this.fragConfig.fragFocusClass);
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
}, {
|
|
@@ -210,7 +212,7 @@ var InnerList = /* @__PURE__ */ function() {
|
|
|
210
212
|
value: function setHightLight(index) {
|
|
211
213
|
var children = this.root.children;
|
|
212
214
|
if (index < children.length) {
|
|
213
|
-
addClass(children[index], this.fragConfig.fragFocusClass);
|
|
215
|
+
util.addClass(children[index], this.fragConfig.fragFocusClass);
|
|
214
216
|
return {
|
|
215
217
|
dom: children[index],
|
|
216
218
|
pos: children[index].getBoundingClientRect()
|
|
@@ -255,17 +257,17 @@ var InnerList = /* @__PURE__ */ function() {
|
|
|
255
257
|
var _this3 = this;
|
|
256
258
|
var progressColor = this.style.progressColor;
|
|
257
259
|
if (!this.root) {
|
|
258
|
-
this.root = createDom("xg-inners", "", {}, "progress-list");
|
|
260
|
+
this.root = util.createDom("xg-inners", "", {}, "progress-list");
|
|
259
261
|
}
|
|
260
262
|
if (this.fragments) {
|
|
261
263
|
var _this$fragConfig = this.fragConfig, fragClass = _this$fragConfig.fragClass, fragFocusClass = _this$fragConfig.fragFocusClass;
|
|
262
264
|
this.progressList = this.fragments.map(function(item) {
|
|
263
|
-
var inner = createDom("xg-inner", "", {
|
|
265
|
+
var inner = util.createDom("xg-inner", "", {
|
|
264
266
|
style: progressColor ? "background:".concat(progressColor, "; flex: ").concat(item.percent) : "flex: ".concat(item.percent)
|
|
265
267
|
}, "".concat(item.isFocus ? fragFocusClass : "", " xgplayer-progress-inner ").concat(fragClass));
|
|
266
268
|
_this3.root.appendChild(inner);
|
|
267
269
|
TPL.forEach(function(item2) {
|
|
268
|
-
inner.appendChild(createDom(item2.tag, "", {
|
|
270
|
+
inner.appendChild(util.createDom(item2.tag, "", {
|
|
269
271
|
style: item2.styleKey ? "background: ".concat(_this3.style[item2.styleKey], "; width:0;") : "width:0;"
|
|
270
272
|
}, item2.className));
|
|
271
273
|
});
|
|
@@ -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 from "../../plugin/plugin.js";
|
|
4
5
|
function getBgColor(color) {
|