xgplayer 3.0.24 → 3.0.25-alpha.0
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/lang/zh-hk.js +1 -1
- package/es/mediaProxy.d.ts +17 -6
- package/es/mediaProxy.js +35 -21
- package/es/player.d.ts +2 -2
- package/es/player.js +6 -6
- package/es/plugin/plugin.d.ts +2 -0
- package/es/plugin/plugin.js +3 -1
- package/es/plugin/pluginsManager.d.ts +14 -14
- package/es/plugin/pluginsManager.js +22 -9
- package/es/plugins/keyboard/index.js +1 -1
- package/es/plugins/pc/index.js +1 -1
- package/es/plugins/pip/index.js +2 -0
- package/es/plugins/progress/index.d.ts +5 -0
- package/es/plugins/progress/index.js +52 -6
- package/es/plugins/progress/innerList.js +1 -1
- package/es/plugins/progressPreview/dotsApi.js +1 -1
- package/es/plugins/rotate/index.d.ts +1 -0
- package/es/plugins/rotate/index.js +6 -0
- package/es/plugins/stats/index.js +1 -1
- package/es/plugins/time/timesegments.js +1 -1
- package/es/utils/sniffer.js +1 -1
- package/es/utils/util.d.ts +57 -55
- package/es/utils/util.js +2 -0
- package/es/version.js +1 -1
- package/package.json +3 -3
package/es/lang/zh-hk.js
CHANGED
package/es/mediaProxy.d.ts
CHANGED
|
@@ -121,6 +121,23 @@ declare class MediaProxy {
|
|
|
121
121
|
* @param { any } [media]
|
|
122
122
|
*/
|
|
123
123
|
detachVideoEvents(media?: any): void;
|
|
124
|
+
/**
|
|
125
|
+
* @description Assemble source elements for the media element,
|
|
126
|
+
* and add error event listeners to each source element
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
public assembleSource(urls: any, mediaEl: any): void;
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
private _videoSourceCount;
|
|
134
|
+
_videoSourceIndex: any;
|
|
135
|
+
_sourceError: (e: any) => void;
|
|
136
|
+
/**
|
|
137
|
+
* @description disassemble source elements for the media element
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
public disassembleSource(mediaEl: any): void;
|
|
124
141
|
/**
|
|
125
142
|
* 针对source列表播放方式添加错误监听
|
|
126
143
|
* @doc https://stackoverflow.com/questions/47557135/html5-detect-the-type-of-error-when-trying-to-load-a-video-using-a-source-elem
|
|
@@ -132,13 +149,7 @@ declare class MediaProxy {
|
|
|
132
149
|
src: string;
|
|
133
150
|
type: string;
|
|
134
151
|
}>): void;
|
|
135
|
-
/**
|
|
136
|
-
* @private
|
|
137
|
-
*/
|
|
138
|
-
private _videoSourceCount;
|
|
139
|
-
_videoSourceIndex: number;
|
|
140
152
|
_vLoadeddata: (e: any) => void;
|
|
141
|
-
_sourceError: (e: any) => void;
|
|
142
153
|
/**
|
|
143
154
|
* 移除source列表错误事件监听
|
|
144
155
|
* @protected
|
package/es/mediaProxy.js
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from "eventemitter3";
|
|
|
3
3
|
import util from "./utils/util.js";
|
|
4
4
|
import sniffer from "./utils/sniffer.js";
|
|
5
5
|
import Errors, { ERROR_TYPE_MAP } from "./error.js";
|
|
6
|
-
import { VIDEO_EVENTS,
|
|
6
|
+
import { VIDEO_EVENTS, SOURCE_ERROR, SOURCE_SUCCESS, URL_CHANGE, WAITING } from "./events.js";
|
|
7
7
|
function emitVideoEvent(eventKey, e) {
|
|
8
8
|
if (!this || !this.emit) {
|
|
9
9
|
return;
|
|
@@ -183,30 +183,20 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
183
183
|
this._evHandlers = null;
|
|
184
184
|
}
|
|
185
185
|
}, {
|
|
186
|
-
key: "
|
|
187
|
-
value: function
|
|
186
|
+
key: "assembleSource",
|
|
187
|
+
value: function assembleSource(urls, mediaEl) {
|
|
188
188
|
var _this6 = this;
|
|
189
|
-
video
|
|
190
|
-
video.load();
|
|
189
|
+
var media = mediaEl || this.media || this.video;
|
|
191
190
|
urls.forEach(function(item, index) {
|
|
192
|
-
|
|
191
|
+
media.appendChild(util.createDom("source", "", {
|
|
193
192
|
src: "".concat(item.src),
|
|
194
193
|
type: "".concat(item.type || ""),
|
|
195
194
|
"data-index": index + 1
|
|
196
195
|
}));
|
|
197
196
|
});
|
|
198
|
-
var _c =
|
|
199
|
-
if (!_c) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
197
|
+
var _c = media.children;
|
|
202
198
|
this._videoSourceCount = _c.length;
|
|
203
199
|
this._videoSourceIndex = _c.length;
|
|
204
|
-
this._vLoadeddata = function(e) {
|
|
205
|
-
_this6.emit(SOURCE_SUCCESS, {
|
|
206
|
-
src: e.target.currentSrc,
|
|
207
|
-
host: util.getHostFromUrl(e.target.currentSrc)
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
200
|
var _eHandler = null;
|
|
211
201
|
for (var i = 0; i < this._evHandlers.length; i++) {
|
|
212
202
|
if (Object.keys(this._evHandlers[i])[0] === "error") {
|
|
@@ -239,12 +229,12 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
239
229
|
for (var _i = 0; _i < _c.length; _i++) {
|
|
240
230
|
_c[_i].addEventListener("error", this._sourceError);
|
|
241
231
|
}
|
|
242
|
-
video.addEventListener("loadeddata", this._vLoadeddata);
|
|
243
232
|
}
|
|
244
233
|
}, {
|
|
245
|
-
key: "
|
|
246
|
-
value: function
|
|
247
|
-
var
|
|
234
|
+
key: "disassembleSource",
|
|
235
|
+
value: function disassembleSource(mediaEl) {
|
|
236
|
+
var media = mediaEl || this.media || this.video;
|
|
237
|
+
var _c = media.children;
|
|
248
238
|
if (!_c || _c.length === 0 || !this._sourceError) {
|
|
249
239
|
return;
|
|
250
240
|
}
|
|
@@ -252,8 +242,32 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
252
242
|
_c[i].removeEventListener("error", this._sourceError);
|
|
253
243
|
}
|
|
254
244
|
while (_c.length > 0) {
|
|
255
|
-
|
|
245
|
+
media.removeChild(_c[0]);
|
|
256
246
|
}
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
key: "_attachSourceEvents",
|
|
250
|
+
value: function _attachSourceEvents(video, urls) {
|
|
251
|
+
var _this7 = this;
|
|
252
|
+
video.removeAttribute("src");
|
|
253
|
+
video.load();
|
|
254
|
+
this.assembleSource(video, urls);
|
|
255
|
+
var _c = video.children;
|
|
256
|
+
if (!_c) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this._vLoadeddata = function(e) {
|
|
260
|
+
_this7.emit(SOURCE_SUCCESS, {
|
|
261
|
+
src: e.target.currentSrc,
|
|
262
|
+
host: util.getHostFromUrl(e.target.currentSrc)
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
video.addEventListener("loadeddata", this._vLoadeddata);
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "_detachSourceEvents",
|
|
269
|
+
value: function _detachSourceEvents(video) {
|
|
270
|
+
this.disassembleSource(video);
|
|
257
271
|
this._vLoadeddata && video.removeEventListener("loadeddata", this._vLoadeddata);
|
|
258
272
|
}
|
|
259
273
|
}, {
|
package/es/player.d.ts
CHANGED
|
@@ -373,10 +373,10 @@ declare class Player extends MediaProxy {
|
|
|
373
373
|
};
|
|
374
374
|
/**
|
|
375
375
|
* get a plugin instance
|
|
376
|
-
* @param { string }
|
|
376
|
+
* @param { string | function } condition
|
|
377
377
|
* @return { null | any } plugin
|
|
378
378
|
*/
|
|
379
|
-
getPlugin(
|
|
379
|
+
getPlugin(condition: string | Function): null | any;
|
|
380
380
|
/**
|
|
381
381
|
*
|
|
382
382
|
* @param { string } className
|
package/es/player.js
CHANGED
|
@@ -28,7 +28,7 @@ export { default as I18N } from "./lang/i18n.js";
|
|
|
28
28
|
import version from "./version.js";
|
|
29
29
|
import { STATES, STATE_ARRAY } from "./state.js";
|
|
30
30
|
import { InstManager, checkPlayerRoot } from "./instManager.js";
|
|
31
|
-
var
|
|
31
|
+
var PLAYER_HOOKS = ["play", "pause", "replay", "retry"];
|
|
32
32
|
var REAL_TIME_SPEED = 0;
|
|
33
33
|
var AVG_SPEED = 0;
|
|
34
34
|
var instManager = null;
|
|
@@ -120,7 +120,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
120
120
|
_defineProperty(_assertThisInitialized(_this), "_onWebkitendfullscreen", function(e) {
|
|
121
121
|
_this.onFullscreenChange(e, false);
|
|
122
122
|
});
|
|
123
|
-
hooksDescriptor(_assertThisInitialized(_this),
|
|
123
|
+
hooksDescriptor(_assertThisInitialized(_this), PLAYER_HOOKS);
|
|
124
124
|
_this.config = _config;
|
|
125
125
|
_this._pluginInfoId = util.generateSessionId();
|
|
126
126
|
bindDebug(_assertThisInitialized(_this));
|
|
@@ -250,7 +250,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
250
250
|
handle: "Constructor",
|
|
251
251
|
msg: "container id can't be empty"
|
|
252
252
|
}));
|
|
253
|
-
console.error("this.
|
|
253
|
+
console.error("this.config.id or this.config.el can't be empty");
|
|
254
254
|
return false;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
@@ -573,9 +573,9 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
573
573
|
}
|
|
574
574
|
}, {
|
|
575
575
|
key: "getPlugin",
|
|
576
|
-
value: function getPlugin(
|
|
577
|
-
var plugin = pluginsManager.findPlugin(this,
|
|
578
|
-
return plugin && plugin.pluginName ? plugin : null;
|
|
576
|
+
value: function getPlugin(condition) {
|
|
577
|
+
var plugin = pluginsManager.findPlugin(this, condition);
|
|
578
|
+
return plugin !== null && plugin !== void 0 && plugin.pluginName ? plugin : null;
|
|
579
579
|
}
|
|
580
580
|
}, {
|
|
581
581
|
key: "addClass",
|
package/es/plugin/plugin.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ declare class Plugin extends BasePlugin {
|
|
|
46
46
|
* @returns
|
|
47
47
|
*/
|
|
48
48
|
static delegate(root: HTMLElement, querySelector: string, eventType: string | Array<string>, callback: Function, capture?: boolean): any[];
|
|
49
|
+
static iconTip: typeof xgIconTips;
|
|
49
50
|
static get ROOT_TYPES(): {
|
|
50
51
|
CONTROLS: string;
|
|
51
52
|
ROOT: string;
|
|
@@ -219,4 +220,5 @@ export namespace PLUGIN_STATE_CLASS {
|
|
|
219
220
|
const ICON_HIDE: string;
|
|
220
221
|
}
|
|
221
222
|
import BasePlugin from "./basePlugin";
|
|
223
|
+
import { xgIconTips } from "../plugins/common/iconTools";
|
|
222
224
|
export { Plugin as default };
|
package/es/plugin/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, get as _get, getPrototypeOf as _getPrototypeOf, typeof as _typeof } from "../_virtual/_rollupPluginBabelHelpers.js";
|
|
1
|
+
import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, get as _get, getPrototypeOf as _getPrototypeOf, typeof as _typeof } from "../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
2
|
import BasePlugin from "./basePlugin.js";
|
|
3
3
|
import _delegate from "delegate";
|
|
4
|
+
import { xgIconTips } from "../plugins/common/iconTools.js";
|
|
4
5
|
import XG_DEBUG from "../utils/debug.js";
|
|
5
6
|
import util from "../utils/util.js";
|
|
6
7
|
var ROOT_TYPES = {
|
|
@@ -557,4 +558,5 @@ var Plugin = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
557
558
|
}]);
|
|
558
559
|
return Plugin2;
|
|
559
560
|
}(BasePlugin);
|
|
561
|
+
_defineProperty(Plugin, "iconTip", xgIconTips);
|
|
560
562
|
export { PLUGIN_STATE_CLASS, POSITIONS, ROOT_TYPES, Plugin as default };
|
|
@@ -62,20 +62,20 @@ declare namespace pluginsManager {
|
|
|
62
62
|
*/
|
|
63
63
|
function lazyRegister(player: any, lazyPlugin: any): Promise<any>;
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
* register a Plugin
|
|
66
|
+
* @param { any } player the plugins register
|
|
67
|
+
* @param { any } plugin the plugin contructor
|
|
68
|
+
* @param { any } options the plugin configuration
|
|
69
|
+
* @return { any } Plugin the plugin instance
|
|
70
|
+
**/
|
|
71
71
|
function register(player: any, plugin: any, options?: any): any;
|
|
72
72
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
* register a Plugin
|
|
74
|
+
* @param { any } player the plugins register
|
|
75
|
+
* @param { any } plugin the plugin contructor
|
|
76
|
+
* @param { any } options the plugin configuration
|
|
77
|
+
* @return { any } Plugin the plugin instance
|
|
78
|
+
**/
|
|
79
79
|
function register(player: any, plugin: any, options?: any): any;
|
|
80
80
|
/**
|
|
81
81
|
* Unregister a plugin from player instance
|
|
@@ -111,8 +111,8 @@ declare namespace pluginsManager {
|
|
|
111
111
|
* @param { any } player
|
|
112
112
|
*/
|
|
113
113
|
function getPlugins(player: any): any;
|
|
114
|
-
function findPlugin(player: any,
|
|
115
|
-
function findPlugin(player: any,
|
|
114
|
+
function findPlugin(player: any, condition: any): any;
|
|
115
|
+
function findPlugin(player: any, condition: any): any;
|
|
116
116
|
function beforeInit(player: any): Promise<any>;
|
|
117
117
|
function beforeInit(player: any): Promise<any>;
|
|
118
118
|
function afterInit(player: any): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addObserver, unObserver } from "./resizeObserver.js";
|
|
2
1
|
import util from "../utils/util.js";
|
|
2
|
+
import { addObserver, unObserver } from "./resizeObserver.js";
|
|
3
3
|
var pluginsManager = {
|
|
4
4
|
pluginGroup: {},
|
|
5
5
|
init: function init(player) {
|
|
@@ -64,13 +64,13 @@ var pluginsManager = {
|
|
|
64
64
|
var timeout = lazyPlugin.timeout || 1500;
|
|
65
65
|
return Promise.race([lazyPlugin.loader().then(function(plugin) {
|
|
66
66
|
var result;
|
|
67
|
-
if (plugin && plugin.__esModule) {
|
|
67
|
+
if (plugin !== null && plugin !== void 0 && plugin.__esModule) {
|
|
68
68
|
result = plugin.default;
|
|
69
69
|
} else {
|
|
70
70
|
result = plugin;
|
|
71
71
|
}
|
|
72
72
|
_this.register(player, result, plugin.options);
|
|
73
|
-
}), new Promise(function(
|
|
73
|
+
}), new Promise(function(_, reject) {
|
|
74
74
|
setTimeout(function() {
|
|
75
75
|
reject(new Error("timeout"));
|
|
76
76
|
}, timeout);
|
|
@@ -169,13 +169,23 @@ var pluginsManager = {
|
|
|
169
169
|
var cgid = player._pluginInfoId;
|
|
170
170
|
return cgid && this.pluginGroup[cgid] ? this.pluginGroup[cgid]._plugins : {};
|
|
171
171
|
},
|
|
172
|
-
findPlugin: function findPlugin(player,
|
|
172
|
+
findPlugin: function findPlugin(player, condition) {
|
|
173
173
|
var cgid = player._pluginInfoId;
|
|
174
174
|
if (!cgid || !this.pluginGroup[cgid]) {
|
|
175
175
|
return null;
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
if (typeof condition === "string") {
|
|
178
|
+
var cName = condition.toLowerCase();
|
|
179
|
+
return this.pluginGroup[cgid]._plugins[cName] || null;
|
|
180
|
+
} else if (typeof condition === "function") {
|
|
181
|
+
var plugins = this.pluginGroup[cgid]._plugins;
|
|
182
|
+
for (var key in plugins) {
|
|
183
|
+
if (condition(plugins[key])) {
|
|
184
|
+
return plugins[key] || null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
179
189
|
},
|
|
180
190
|
beforeInit: function beforeInit(player) {
|
|
181
191
|
var _this2 = this;
|
|
@@ -189,11 +199,12 @@ var pluginsManager = {
|
|
|
189
199
|
}
|
|
190
200
|
}
|
|
191
201
|
return new Promise(function(resolve) {
|
|
202
|
+
var _player$_loadingPlugi;
|
|
192
203
|
if (!_this2.pluginGroup) {
|
|
193
204
|
return;
|
|
194
205
|
}
|
|
195
206
|
var prevTask;
|
|
196
|
-
if (player._loadingPlugins &&
|
|
207
|
+
if ((_player$_loadingPlugi = player._loadingPlugins) !== null && _player$_loadingPlugi !== void 0 && _player$_loadingPlugi.length) {
|
|
197
208
|
prevTask = Promise.all(player._loadingPlugins);
|
|
198
209
|
} else {
|
|
199
210
|
prevTask = Promise.resolve();
|
|
@@ -207,7 +218,8 @@ var pluginsManager = {
|
|
|
207
218
|
var plugins = _this2.pluginGroup[cgid]._plugins;
|
|
208
219
|
var pluginsRet = [];
|
|
209
220
|
Object.keys(plugins).forEach(function(pName) {
|
|
210
|
-
|
|
221
|
+
var _plugins$pName;
|
|
222
|
+
if ((_plugins$pName = plugins[pName]) !== null && _plugins$pName !== void 0 && _plugins$pName.beforePlayerInit) {
|
|
211
223
|
try {
|
|
212
224
|
var ret = plugins[pName].beforePlayerInit();
|
|
213
225
|
pluginsRet.push(retPromise(ret));
|
|
@@ -233,7 +245,8 @@ var pluginsManager = {
|
|
|
233
245
|
}
|
|
234
246
|
var plugins = this.pluginGroup[cgid]._plugins;
|
|
235
247
|
Object.keys(plugins).forEach(function(pName) {
|
|
236
|
-
|
|
248
|
+
var _plugins$pName2;
|
|
249
|
+
if ((_plugins$pName2 = plugins[pName]) !== null && _plugins$pName2 !== void 0 && _plugins$pName2.afterPlayerInit) {
|
|
237
250
|
plugins[pName].afterPlayerInit();
|
|
238
251
|
}
|
|
239
252
|
});
|
|
@@ -2,7 +2,7 @@ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _
|
|
|
2
2
|
import util from "../../utils/util.js";
|
|
3
3
|
import { SHORTCUT } from "../../events.js";
|
|
4
4
|
import BasePlugin from "../../plugin/basePlugin.js";
|
|
5
|
-
import "
|
|
5
|
+
import "../../plugin/plugin.js";
|
|
6
6
|
function preventDefault(e) {
|
|
7
7
|
e.preventDefault();
|
|
8
8
|
e.returnValue = false;
|
package/es/plugins/pc/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import "../../utils/util.js";
|
|
|
3
3
|
import sniffer from "../../utils/sniffer.js";
|
|
4
4
|
import { ENTER_PLAYER, LEAVE_PLAYER } from "../../events.js";
|
|
5
5
|
import BasePlugin from "../../plugin/basePlugin.js";
|
|
6
|
-
import "
|
|
6
|
+
import "../../plugin/plugin.js";
|
|
7
7
|
import { runHooks } from "../../plugin/hooksDescriptor.js";
|
|
8
8
|
var MOUSE_EVENTS = {
|
|
9
9
|
mouseenter: "onMouseEnter",
|
package/es/plugins/pip/index.js
CHANGED
|
@@ -206,6 +206,8 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
206
206
|
pipWin.document.head.append(styles);
|
|
207
207
|
pipWin.document.body.append(pipRoot);
|
|
208
208
|
pipWin.addEventListener("pagehide", function(event) {
|
|
209
|
+
var _player$plugins, _player$plugins$progr, _player$plugins$progr2;
|
|
210
|
+
(_player$plugins = player.plugins) === null || _player$plugins === void 0 ? void 0 : (_player$plugins$progr = _player$plugins.progress) === null || _player$plugins$progr === void 0 ? void 0 : (_player$plugins$progr2 = _player$plugins$progr.resetDragState) === null || _player$plugins$progr2 === void 0 ? void 0 : _player$plugins$progr2.call(_player$plugins$progr);
|
|
209
211
|
if (parentNode) {
|
|
210
212
|
if (nextSibling) {
|
|
211
213
|
parentNode.insertBefore(pipRoot, nextSibling);
|
|
@@ -112,6 +112,10 @@ declare class Progress extends Plugin {
|
|
|
112
112
|
_mouseDownHandlerHook: any;
|
|
113
113
|
_mouseUpHandlerHook: any;
|
|
114
114
|
_mouseMoveHandlerHook: any;
|
|
115
|
+
_getRootDocument(): Document;
|
|
116
|
+
_addDragDocumentEvents(): void;
|
|
117
|
+
_dragDocument: Document;
|
|
118
|
+
_removeDragDocumentEvents(): void;
|
|
115
119
|
focus(): void;
|
|
116
120
|
blur(): void;
|
|
117
121
|
disableBlur(): void;
|
|
@@ -128,6 +132,7 @@ declare class Progress extends Plugin {
|
|
|
128
132
|
_mouseMoveHandler: (e: any, data: any) => void;
|
|
129
133
|
onMouseDown: (e: any) => boolean;
|
|
130
134
|
onMouseUp: (e: any) => void;
|
|
135
|
+
resetDragState(): void;
|
|
131
136
|
onMouseMove: (e: any) => void;
|
|
132
137
|
onMouseOut: (e: any) => void;
|
|
133
138
|
onMouseOver: (e: any) => void;
|
|
@@ -103,8 +103,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
103
103
|
_this.root.addEventListener("touchcancel", _this.onMouseUp);
|
|
104
104
|
} else {
|
|
105
105
|
_this.unbind("mousemove", _this.onMoveOnly);
|
|
106
|
-
|
|
107
|
-
document.addEventListener("mouseup", _this.onMouseUp, false);
|
|
106
|
+
_this._addDragDocumentEvents();
|
|
108
107
|
}
|
|
109
108
|
return true;
|
|
110
109
|
});
|
|
@@ -143,8 +142,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
143
142
|
_this.root.removeEventListener("touchcancel", _this.onMouseUp);
|
|
144
143
|
_this.blur();
|
|
145
144
|
} else {
|
|
146
|
-
|
|
147
|
-
document.removeEventListener("mouseup", _this.onMouseUp, false);
|
|
145
|
+
_this._removeDragDocumentEvents();
|
|
148
146
|
if (!pos.isEnter) {
|
|
149
147
|
_this.onMouseLeave(e);
|
|
150
148
|
} else {
|
|
@@ -451,6 +449,28 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
451
449
|
this.player.root.addEventListener("click", this.onBodyClick, true);
|
|
452
450
|
}
|
|
453
451
|
}
|
|
452
|
+
}, {
|
|
453
|
+
key: "_getRootDocument",
|
|
454
|
+
value: function _getRootDocument() {
|
|
455
|
+
var _this$root;
|
|
456
|
+
return ((_this$root = this.root) === null || _this$root === void 0 ? void 0 : _this$root.ownerDocument) || document;
|
|
457
|
+
}
|
|
458
|
+
}, {
|
|
459
|
+
key: "_addDragDocumentEvents",
|
|
460
|
+
value: function _addDragDocumentEvents() {
|
|
461
|
+
var dragDocument = this._getRootDocument();
|
|
462
|
+
this._dragDocument = dragDocument;
|
|
463
|
+
dragDocument.addEventListener("mousemove", this.onMouseMove, false);
|
|
464
|
+
dragDocument.addEventListener("mouseup", this.onMouseUp, false);
|
|
465
|
+
}
|
|
466
|
+
}, {
|
|
467
|
+
key: "_removeDragDocumentEvents",
|
|
468
|
+
value: function _removeDragDocumentEvents() {
|
|
469
|
+
var dragDocument = this._dragDocument || this._getRootDocument();
|
|
470
|
+
dragDocument.removeEventListener("mousemove", this.onMouseMove, false);
|
|
471
|
+
dragDocument.removeEventListener("mouseup", this.onMouseUp, false);
|
|
472
|
+
this._dragDocument = null;
|
|
473
|
+
}
|
|
454
474
|
}, {
|
|
455
475
|
key: "focus",
|
|
456
476
|
value: function focus() {
|
|
@@ -476,6 +496,33 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
476
496
|
value: function enableBlur() {
|
|
477
497
|
this._disableBlur = false;
|
|
478
498
|
}
|
|
499
|
+
}, {
|
|
500
|
+
key: "resetDragState",
|
|
501
|
+
value: function resetDragState() {
|
|
502
|
+
var pos = this.pos, playerConfig = this.playerConfig, config = this.config;
|
|
503
|
+
if (!pos) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
this.root.removeEventListener("touchmove", this.onMouseMove);
|
|
507
|
+
this.root.removeEventListener("touchend", this.onMouseUp);
|
|
508
|
+
this.root.removeEventListener("touchcancel", this.onMouseUp);
|
|
509
|
+
this._removeDragDocumentEvents();
|
|
510
|
+
if (!pos.isDown && !this.isProgressMoving) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
util.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
|
|
514
|
+
util.checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
|
|
515
|
+
util.removeClass(this.progressBtn, "active");
|
|
516
|
+
pos.moving = false;
|
|
517
|
+
pos.isDown = false;
|
|
518
|
+
pos.x = 0;
|
|
519
|
+
pos.y = 0;
|
|
520
|
+
pos.isLocked = false;
|
|
521
|
+
this._state.prePlayTime = 0;
|
|
522
|
+
this._state.time = 0;
|
|
523
|
+
this.resetSeekState();
|
|
524
|
+
this.blur();
|
|
525
|
+
}
|
|
479
526
|
}, {
|
|
480
527
|
key: "updateWidth",
|
|
481
528
|
value: function updateWidth(currentTime, seekTime, percent, type) {
|
|
@@ -628,8 +675,7 @@ var Progress = /* @__PURE__ */ function(_Plugin) {
|
|
|
628
675
|
this.unbind("mouseenter", this.onMouseEnter);
|
|
629
676
|
this.unbind("mousemove", this.onMoveOnly);
|
|
630
677
|
this.unbind("mouseleave", this.onMouseLeave);
|
|
631
|
-
|
|
632
|
-
document.removeEventListener("mouseup", this.onMouseUp, false);
|
|
678
|
+
this._removeDragDocumentEvents();
|
|
633
679
|
player.root.removeEventListener("click", this.onBodyClick, true);
|
|
634
680
|
}
|
|
635
681
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createClass as _createClass, classCallCheck as _classCallCheck } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
2
|
import util from "../../utils/util.js";
|
|
3
3
|
import "../../utils/debug.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../../plugin/plugin.js";
|
|
5
5
|
var TPL = [{
|
|
6
6
|
tag: "xg-cache",
|
|
7
7
|
className: "xgplayer-progress-cache",
|
|
@@ -10,6 +10,7 @@ export default class Rotate extends IconPlugin {
|
|
|
10
10
|
constructor(args: any);
|
|
11
11
|
rotateDeg: any;
|
|
12
12
|
onBtnClick(e: any): void;
|
|
13
|
+
_clickTimeStamp: number;
|
|
13
14
|
rootWidth: string | number;
|
|
14
15
|
rootHeight: string | number;
|
|
15
16
|
updateRotateDeg(rotateDeg: any, innerRotate: any): void;
|
|
@@ -26,6 +26,7 @@ var Rotate = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
26
26
|
_get(_getPrototypeOf(Rotate2.prototype), "afterCreate", this).call(this);
|
|
27
27
|
this.appendChild(".xgplayer-icon", this.icons.rotate);
|
|
28
28
|
this.onBtnClick = this.onBtnClick.bind(this);
|
|
29
|
+
this._clickTimeStamp = 0;
|
|
29
30
|
this.bind(".xgplayer-icon", ["click", "touchend"], this.onBtnClick);
|
|
30
31
|
this.on(VIDEO_RESIZE, function() {
|
|
31
32
|
if (_this2.rotateDeg && _this2.config.innerRotate) {
|
|
@@ -50,6 +51,11 @@ var Rotate = /* @__PURE__ */ function(_IconPlugin) {
|
|
|
50
51
|
}, {
|
|
51
52
|
key: "onBtnClick",
|
|
52
53
|
value: function onBtnClick(e) {
|
|
54
|
+
var now = Date.now();
|
|
55
|
+
if (now - this._clickTimeStamp < 300) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this._clickTimeStamp = now;
|
|
53
59
|
e.preventDefault();
|
|
54
60
|
e.stopPropagation();
|
|
55
61
|
this.emitUserAction(e, "rotate");
|
|
@@ -2,7 +2,7 @@ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _
|
|
|
2
2
|
import "../../utils/util.js";
|
|
3
3
|
import { USER_ACTION, STATS_EVENTS as STATS_EVENTS$1 } from "../../events.js";
|
|
4
4
|
import BasePlugin from "../../plugin/basePlugin.js";
|
|
5
|
-
import "
|
|
5
|
+
import "../../plugin/plugin.js";
|
|
6
6
|
var INFO = "info";
|
|
7
7
|
var STATS_EVENTS = STATS_EVENTS$1;
|
|
8
8
|
var Stats = /* @__PURE__ */ function(_BasePlugin) {
|
|
@@ -2,7 +2,7 @@ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _
|
|
|
2
2
|
import util from "../../utils/util.js";
|
|
3
3
|
import { DURATION_CHANGE, LOADED_DATA, TIME_UPDATE, SEEKING, PLAY } from "../../events.js";
|
|
4
4
|
import BasePlugin from "../../plugin/basePlugin.js";
|
|
5
|
-
import "
|
|
5
|
+
import "../../plugin/plugin.js";
|
|
6
6
|
var TimeSegmentsControls = /* @__PURE__ */ function(_BasePlugin) {
|
|
7
7
|
_inherits(TimeSegmentsControls2, _BasePlugin);
|
|
8
8
|
var _super = _createSuper(TimeSegmentsControls2);
|