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