@volcengine/veplayer 2.0.0-rc.2 → 2.1.0-rc.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/README.md +14 -1
- package/esm/index.d.ts +17 -11
- package/esm/veplayer.biz.live.development.js +184 -45
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +53 -28
- package/esm/veplayer.development.css +1 -1
- package/esm/veplayer.development.js +600 -234
- package/esm/veplayer.live.d.ts +53 -28
- package/esm/veplayer.live.development.css +1 -1
- package/esm/veplayer.live.development.js +600 -234
- package/esm/veplayer.live.production.css +1 -1
- package/esm/veplayer.live.production.js +4 -4
- package/esm/veplayer.production.css +1 -1
- package/esm/veplayer.production.js +4 -4
- package/esm/veplayer.vod.d.ts +17 -11
- package/esm/veplayer.vod.development.css +1 -1
- package/esm/veplayer.vod.development.js +402 -173
- package/esm/veplayer.vod.production.css +1 -1
- package/esm/veplayer.vod.production.js +4 -4
- package/package.json +2 -1
- package/umd/index.d.ts +17 -11
- package/umd/veplayer.biz.live.development.js +184 -45
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +53 -28
- package/umd/veplayer.development.css +1 -1
- package/umd/veplayer.development.js +600 -234
- package/umd/veplayer.live.d.ts +53 -28
- package/umd/veplayer.live.development.css +1 -1
- package/umd/veplayer.live.development.js +598 -232
- package/umd/veplayer.live.production.css +1 -1
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.css +1 -1
- package/umd/veplayer.production.js +1 -1
- package/umd/veplayer.vod.d.ts +17 -11
- package/umd/veplayer.vod.development.css +1 -1
- package/umd/veplayer.vod.development.js +402 -173
- package/umd/veplayer.vod.production.css +1 -1
- package/umd/veplayer.vod.production.js +1 -1
|
@@ -1010,6 +1010,9 @@ util.isMSE = function(video) {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
return /^blob/.test(video.currentSrc) || /^blob/.test(video.src);
|
|
1012
1012
|
};
|
|
1013
|
+
util.isBlob = function(url) {
|
|
1014
|
+
return /^blob/.test(url);
|
|
1015
|
+
};
|
|
1013
1016
|
util.generateSessionId = function() {
|
|
1014
1017
|
var did = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
1015
1018
|
var d = (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -1070,6 +1073,69 @@ util.convertDeg = function(val) {
|
|
|
1070
1073
|
}
|
|
1071
1074
|
return val % 360;
|
|
1072
1075
|
};
|
|
1076
|
+
util.getIndexByTime = function(time, segments) {
|
|
1077
|
+
var _len = segments.length;
|
|
1078
|
+
var _index = -1;
|
|
1079
|
+
if (_len < 1) {
|
|
1080
|
+
return _index;
|
|
1081
|
+
}
|
|
1082
|
+
if (time <= segments[0].end || _len < 2) {
|
|
1083
|
+
_index = 0;
|
|
1084
|
+
} else if (time > segments[_len - 1].end) {
|
|
1085
|
+
_index = _len - 1;
|
|
1086
|
+
} else {
|
|
1087
|
+
for (var i = 1; i < _len; i++) {
|
|
1088
|
+
if (time > segments[i - 1].end && time <= segments[i].end) {
|
|
1089
|
+
_index = i;
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return _index;
|
|
1095
|
+
};
|
|
1096
|
+
util.getOffsetCurrentTime = function(currentTime, segments) {
|
|
1097
|
+
var index = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : -1;
|
|
1098
|
+
var _index = -1;
|
|
1099
|
+
if (index >= 0 && index < segments.length) {
|
|
1100
|
+
_index = index;
|
|
1101
|
+
} else {
|
|
1102
|
+
_index = util.getIndexByTime(currentTime, segments);
|
|
1103
|
+
}
|
|
1104
|
+
if (_index < 0) {
|
|
1105
|
+
return -1;
|
|
1106
|
+
}
|
|
1107
|
+
var _len = segments.length;
|
|
1108
|
+
var _segments$_index = segments[_index], start = _segments$_index.start, end = _segments$_index.end, cTime = _segments$_index.cTime, offset = _segments$_index.offset;
|
|
1109
|
+
if (currentTime < start) {
|
|
1110
|
+
return cTime;
|
|
1111
|
+
} else if (currentTime >= start && currentTime <= end) {
|
|
1112
|
+
return currentTime - offset;
|
|
1113
|
+
} else if (currentTime > end && _index >= _len - 1) {
|
|
1114
|
+
return end;
|
|
1115
|
+
}
|
|
1116
|
+
return -1;
|
|
1117
|
+
};
|
|
1118
|
+
util.getCurrentTimeByOffset = function(offsetTime, segments) {
|
|
1119
|
+
var _index = -1;
|
|
1120
|
+
if (!segments || segments.length < 0) {
|
|
1121
|
+
return offsetTime;
|
|
1122
|
+
}
|
|
1123
|
+
for (var i = 0; i < segments.length; i++) {
|
|
1124
|
+
if (offsetTime <= segments[i].duration) {
|
|
1125
|
+
_index = i;
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
if (_index !== -1) {
|
|
1130
|
+
var start = segments[_index].start;
|
|
1131
|
+
if (_index - 1 < 0) {
|
|
1132
|
+
return start + offsetTime;
|
|
1133
|
+
} else {
|
|
1134
|
+
return start + (offsetTime - segments[_index - 1].duration);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return offsetTime;
|
|
1138
|
+
};
|
|
1073
1139
|
function isObject(value) {
|
|
1074
1140
|
var type = _typeof(value);
|
|
1075
1141
|
return value !== null && (type === "object" || type === "function");
|
|
@@ -1159,7 +1225,7 @@ function debounce(func, wait, options) {
|
|
|
1159
1225
|
function debounced() {
|
|
1160
1226
|
var time = Date.now();
|
|
1161
1227
|
var isInvoking = shouldInvoke(time);
|
|
1162
|
-
for (var
|
|
1228
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key = 0; _key < _len2; _key++) {
|
|
1163
1229
|
args[_key] = arguments[_key];
|
|
1164
1230
|
}
|
|
1165
1231
|
lastArgs = args;
|
|
@@ -1366,7 +1432,7 @@ var sniffer = {
|
|
|
1366
1432
|
}
|
|
1367
1433
|
}
|
|
1368
1434
|
};
|
|
1369
|
-
var version = "3.0.
|
|
1435
|
+
var version = "3.0.10-alpha.4";
|
|
1370
1436
|
var ERROR_TYPE_MAP = {
|
|
1371
1437
|
1: "media",
|
|
1372
1438
|
2: "media",
|
|
@@ -1452,6 +1518,7 @@ var CANPLAY_THROUGH = "canplaythrough";
|
|
|
1452
1518
|
var DURATION_CHANGE = "durationchange";
|
|
1453
1519
|
var VOLUME_CHANGE = "volumechange";
|
|
1454
1520
|
var LOADED_DATA = "loadeddata";
|
|
1521
|
+
var LOADED_METADATA = "loadedmetadata";
|
|
1455
1522
|
var RATE_CHANGE = "ratechange";
|
|
1456
1523
|
var PROGRESS = "progress";
|
|
1457
1524
|
var LOAD_START = "loadstart";
|
|
@@ -1491,7 +1558,7 @@ var RESET = "reset";
|
|
|
1491
1558
|
var SOURCE_ERROR = "source_error";
|
|
1492
1559
|
var SOURCE_SUCCESS = "source_success";
|
|
1493
1560
|
var SWITCH_SUBTITLE = "switch_subtitle";
|
|
1494
|
-
var VIDEO_EVENTS = ["play", "playing", "ended", "pause", "error", "seeking", "seeked", "timeupdate", "waiting", "canplay", "canplaythrough", "durationchange", "volumechange", "loadeddata", "ratechange", "progress", "loadstart", "emptied", "stalled", "suspend", "abort", "lowdecode"];
|
|
1561
|
+
var VIDEO_EVENTS = ["play", "playing", "ended", "pause", "error", "seeking", "seeked", "timeupdate", "waiting", "canplay", "canplaythrough", "durationchange", "volumechange", "loadeddata", "loadedmetadata", "ratechange", "progress", "loadstart", "emptied", "stalled", "suspend", "abort", "lowdecode"];
|
|
1495
1562
|
var STATS_EVENTS = {
|
|
1496
1563
|
STATS_INFO: "stats_info",
|
|
1497
1564
|
STATS_DOWNLOAD: "stats_download",
|
|
@@ -1520,6 +1587,7 @@ var XGEvents = /* @__PURE__ */ Object.freeze({
|
|
|
1520
1587
|
FPS_STUCK,
|
|
1521
1588
|
FULLSCREEN_CHANGE,
|
|
1522
1589
|
LOADED_DATA,
|
|
1590
|
+
LOADED_METADATA,
|
|
1523
1591
|
LOAD_START,
|
|
1524
1592
|
MINI_STATE_CHANGE,
|
|
1525
1593
|
PAUSE,
|
|
@@ -1657,6 +1725,9 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
1657
1725
|
if (options.loop) {
|
|
1658
1726
|
_this.mediaConfig.loop = "loop";
|
|
1659
1727
|
}
|
|
1728
|
+
if (options.autoplayMuted && !Object.prototype.hasOwnProperty.call(_this.mediaConfig, "muted")) {
|
|
1729
|
+
_this.mediaConfig.muted = true;
|
|
1730
|
+
}
|
|
1660
1731
|
_this.media = util.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
|
|
1661
1732
|
if (options.defaultPlaybackRate) {
|
|
1662
1733
|
_this.media.defaultPlaybackRate = _this.media.playbackRate = options.defaultPlaybackRate;
|
|
@@ -1735,10 +1806,11 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
1735
1806
|
var _this6 = this;
|
|
1736
1807
|
video.removeAttribute("src");
|
|
1737
1808
|
video.load();
|
|
1738
|
-
urls.forEach(function(item) {
|
|
1809
|
+
urls.forEach(function(item, index) {
|
|
1739
1810
|
_this6.media.appendChild(util.createDom("source", "", {
|
|
1740
1811
|
src: "".concat(item.src),
|
|
1741
|
-
type: "".concat(item.type || "")
|
|
1812
|
+
type: "".concat(item.type || ""),
|
|
1813
|
+
"data-index": index + 1
|
|
1742
1814
|
}));
|
|
1743
1815
|
});
|
|
1744
1816
|
var _c = video.children;
|
|
@@ -1746,6 +1818,7 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
1746
1818
|
return;
|
|
1747
1819
|
}
|
|
1748
1820
|
this._videoSourceCount = _c.length;
|
|
1821
|
+
this._videoSourceIndex = _c.length;
|
|
1749
1822
|
this._vLoadeddata = function(e) {
|
|
1750
1823
|
_this6.emit(SOURCE_SUCCESS, {
|
|
1751
1824
|
src: e.target.currentSrc,
|
|
@@ -1760,8 +1833,9 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
1760
1833
|
}
|
|
1761
1834
|
}
|
|
1762
1835
|
!this._sourceError && (this._sourceError = function(e) {
|
|
1763
|
-
|
|
1764
|
-
|
|
1836
|
+
var _dIndex = parseInt(e.target.getAttribute("data-index"), 10);
|
|
1837
|
+
_this6._videoSourceIndex--;
|
|
1838
|
+
if (_this6._videoSourceIndex === 0 || _dIndex >= _this6._videoSourceCount) {
|
|
1765
1839
|
var _err = {
|
|
1766
1840
|
code: 4,
|
|
1767
1841
|
message: "sources_load_error"
|
|
@@ -2088,7 +2162,7 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
2088
2162
|
this.emit(WAITING);
|
|
2089
2163
|
this._currentTime = 0;
|
|
2090
2164
|
this._duration = 0;
|
|
2091
|
-
if (
|
|
2165
|
+
if (util.isMSE(this.media)) {
|
|
2092
2166
|
this.onWaiting();
|
|
2093
2167
|
return;
|
|
2094
2168
|
}
|
|
@@ -3796,6 +3870,7 @@ function getDefaultConfig$1() {
|
|
|
3796
3870
|
},
|
|
3797
3871
|
enableSwipeHandler: function enableSwipeHandler() {
|
|
3798
3872
|
},
|
|
3873
|
+
preProcessUrl: null,
|
|
3799
3874
|
ignores: [],
|
|
3800
3875
|
whitelist: [],
|
|
3801
3876
|
inactive: 3e3,
|
|
@@ -3877,7 +3952,7 @@ var Controls = /* @__PURE__ */ function(_Plugin) {
|
|
|
3877
3952
|
autoHide: false
|
|
3878
3953
|
});
|
|
3879
3954
|
});
|
|
3880
|
-
_defineProperty(_assertThisInitialized(_this), "onMouseLeave", function() {
|
|
3955
|
+
_defineProperty(_assertThisInitialized(_this), "onMouseLeave", function(e) {
|
|
3881
3956
|
var _assertThisInitialize2 = _assertThisInitialized(_this), player = _assertThisInitialize2.player;
|
|
3882
3957
|
player.focus();
|
|
3883
3958
|
});
|
|
@@ -3955,12 +4030,13 @@ var Controls = /* @__PURE__ */ function(_Plugin) {
|
|
|
3955
4030
|
}, {
|
|
3956
4031
|
key: "show",
|
|
3957
4032
|
value: function show() {
|
|
3958
|
-
|
|
4033
|
+
this.root.style.display = "";
|
|
4034
|
+
this.player.focus();
|
|
3959
4035
|
}
|
|
3960
4036
|
}, {
|
|
3961
4037
|
key: "hide",
|
|
3962
4038
|
value: function hide() {
|
|
3963
|
-
|
|
4039
|
+
this.root.style.display = "none";
|
|
3964
4040
|
}
|
|
3965
4041
|
}, {
|
|
3966
4042
|
key: "mode",
|
|
@@ -4362,6 +4438,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4362
4438
|
_this.cssfullscreen = false;
|
|
4363
4439
|
_this.isRotateFullscreen = false;
|
|
4364
4440
|
_this._fullscreenEl = null;
|
|
4441
|
+
_this.timeSegments = [];
|
|
4365
4442
|
_this._cssfullscreenEl = null;
|
|
4366
4443
|
_this.curDefinition = null;
|
|
4367
4444
|
_this._orgCss = "";
|
|
@@ -4371,7 +4448,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4371
4448
|
_this.videoPos = {
|
|
4372
4449
|
pi: 1,
|
|
4373
4450
|
scale: 0,
|
|
4374
|
-
rotate:
|
|
4451
|
+
rotate: -1,
|
|
4375
4452
|
x: 0,
|
|
4376
4453
|
y: 0,
|
|
4377
4454
|
h: -1,
|
|
@@ -4379,11 +4456,21 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4379
4456
|
vy: 0,
|
|
4380
4457
|
vx: 0
|
|
4381
4458
|
};
|
|
4459
|
+
_this.sizeInfo = {
|
|
4460
|
+
width: 0,
|
|
4461
|
+
height: 0,
|
|
4462
|
+
left: 0,
|
|
4463
|
+
top: 0
|
|
4464
|
+
};
|
|
4382
4465
|
_this._accPlayed = {
|
|
4383
4466
|
t: 0,
|
|
4384
4467
|
acc: 0,
|
|
4385
4468
|
loopAcc: 0
|
|
4386
4469
|
};
|
|
4470
|
+
_this._offsetInfo = {
|
|
4471
|
+
currentTime: -1,
|
|
4472
|
+
duration: 0
|
|
4473
|
+
};
|
|
4387
4474
|
_this.innerContainer = null;
|
|
4388
4475
|
_this.controls = null;
|
|
4389
4476
|
_this.topBar = null;
|
|
@@ -4396,6 +4483,9 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4396
4483
|
_this.isUserActive = false;
|
|
4397
4484
|
_this._onceSeekCanplay = null;
|
|
4398
4485
|
_this._isPauseBeforeSeek = 0;
|
|
4486
|
+
_this.innerStates = {
|
|
4487
|
+
isActiveLocked: false
|
|
4488
|
+
};
|
|
4399
4489
|
var rootInit = _this._initDOM();
|
|
4400
4490
|
if (!rootInit) {
|
|
4401
4491
|
console.error(new Error("can't find the dom which id is ".concat(_this.config.id, " or this.config.el does not exist")));
|
|
@@ -4481,16 +4571,16 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4481
4571
|
this.addClass(STATE_CLASS.NO_START);
|
|
4482
4572
|
}
|
|
4483
4573
|
if (this.config.fluid) {
|
|
4484
|
-
var _this$config3 = this.config,
|
|
4485
|
-
if (typeof
|
|
4486
|
-
|
|
4487
|
-
|
|
4574
|
+
var _this$config3 = this.config, _width = _this$config3.width, _height = _this$config3.height;
|
|
4575
|
+
if (typeof _width !== "number" || typeof _height !== "number") {
|
|
4576
|
+
_width = 600;
|
|
4577
|
+
_height = 337.5;
|
|
4488
4578
|
}
|
|
4489
4579
|
var style = {
|
|
4490
4580
|
width: "100%",
|
|
4491
4581
|
height: "0",
|
|
4492
4582
|
"max-width": "100%",
|
|
4493
|
-
"padding-top": "".concat(
|
|
4583
|
+
"padding-top": "".concat(_height * 100 / _width, "%")
|
|
4494
4584
|
};
|
|
4495
4585
|
Object.keys(style).forEach(function(key) {
|
|
4496
4586
|
_this2.root.style[key] = style[key];
|
|
@@ -4506,6 +4596,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4506
4596
|
}
|
|
4507
4597
|
});
|
|
4508
4598
|
}
|
|
4599
|
+
var _this$root$getBoundin = this.root.getBoundingClientRect(), width = _this$root$getBoundin.width, height = _this$root$getBoundin.height, left = _this$root$getBoundin.left, top = _this$root$getBoundin.top;
|
|
4600
|
+
this.sizeInfo.width = width;
|
|
4601
|
+
this.sizeInfo.height = height;
|
|
4602
|
+
this.sizeInfo.left = left;
|
|
4603
|
+
this.sizeInfo.top = top;
|
|
4509
4604
|
return true;
|
|
4510
4605
|
}
|
|
4511
4606
|
}, {
|
|
@@ -4589,7 +4684,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4589
4684
|
var readyState = this.media.readyState;
|
|
4590
4685
|
XG_DEBUG.logInfo("_startInit readyState", readyState);
|
|
4591
4686
|
if (this.config.autoplay) {
|
|
4592
|
-
!
|
|
4687
|
+
!util.isMSE(this.media) && this.load();
|
|
4593
4688
|
(sniffer.os.isIpad || sniffer.os.isPhone) && this.mediaPlay();
|
|
4594
4689
|
}
|
|
4595
4690
|
if (readyState >= 2) {
|
|
@@ -4817,7 +4912,8 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4817
4912
|
if (!url) {
|
|
4818
4913
|
url = _this8.url || _this8.config.url;
|
|
4819
4914
|
}
|
|
4820
|
-
var
|
|
4915
|
+
var _furl = _this8.preProcessUrl(url);
|
|
4916
|
+
var ret = _this8._startInit(_furl.url);
|
|
4821
4917
|
return ret;
|
|
4822
4918
|
}).catch(function(e) {
|
|
4823
4919
|
e.fileName = "player";
|
|
@@ -4834,6 +4930,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
4834
4930
|
if (util.typeOf(url) === "Object") {
|
|
4835
4931
|
_src = url.url;
|
|
4836
4932
|
}
|
|
4933
|
+
_src = this.preProcessUrl(_src).url;
|
|
4837
4934
|
var curTime = this.currentTime;
|
|
4838
4935
|
var isPaused = this.paused && !this.isError;
|
|
4839
4936
|
this.src = _src;
|
|
@@ -5172,7 +5269,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5172
5269
|
this.addClass(STATE_CLASS.LOADING);
|
|
5173
5270
|
runHooks(this, "retry", function() {
|
|
5174
5271
|
var cur = _this20.currentTime;
|
|
5175
|
-
|
|
5272
|
+
var url = _this20.config.url;
|
|
5273
|
+
var _srcRet = !util.isMSE(_this20.media) ? _this20.preProcessUrl(url) : {
|
|
5274
|
+
url
|
|
5275
|
+
};
|
|
5276
|
+
_this20.src = _srcRet.url;
|
|
5176
5277
|
!_this20.config.isLive && (_this20.currentTime = cur);
|
|
5177
5278
|
_this20.once(CANPLAY, function() {
|
|
5178
5279
|
_this20.mediaPlay();
|
|
@@ -5233,7 +5334,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5233
5334
|
var fullEl = util.getFullScreenEl();
|
|
5234
5335
|
if (fullEl === this._fullscreenEl) {
|
|
5235
5336
|
this.onFullscreenChange();
|
|
5236
|
-
return;
|
|
5337
|
+
return Promise.resolve();
|
|
5237
5338
|
}
|
|
5238
5339
|
try {
|
|
5239
5340
|
for (var i = 0; i < GET_FULLSCREEN_API.length; i++) {
|
|
@@ -5406,30 +5507,38 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5406
5507
|
key: "onFocus",
|
|
5407
5508
|
value: function onFocus() {
|
|
5408
5509
|
var _this21 = this;
|
|
5409
|
-
var
|
|
5510
|
+
var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
5511
|
+
autoHide: true,
|
|
5512
|
+
delay: 3e3
|
|
5513
|
+
};
|
|
5514
|
+
var innerStates = this.innerStates;
|
|
5410
5515
|
this.isActive = true;
|
|
5411
5516
|
this.removeClass(STATE_CLASS.INACTIVE);
|
|
5412
5517
|
if (this.userTimer) {
|
|
5413
5518
|
util.clearTimeout(this, this.userTimer);
|
|
5414
5519
|
this.userTimer = null;
|
|
5415
5520
|
}
|
|
5416
|
-
if (
|
|
5521
|
+
if (data.isLock !== void 0) {
|
|
5522
|
+
innerStates.isActiveLocked = data.isLock;
|
|
5523
|
+
}
|
|
5524
|
+
if (data.autoHide === false || data.isLock === true || innerStates.isActiveLocked) {
|
|
5417
5525
|
if (this.userTimer) {
|
|
5418
5526
|
util.clearTimeout(this, this.userTimer);
|
|
5419
5527
|
this.userTimer = null;
|
|
5420
5528
|
}
|
|
5421
5529
|
return;
|
|
5422
5530
|
}
|
|
5531
|
+
var time = data && data.delay ? data.delay : this.config.inactive;
|
|
5423
5532
|
this.userTimer = util.setTimeout(this, function() {
|
|
5424
5533
|
_this21.userTimer = null;
|
|
5425
5534
|
_this21.blur();
|
|
5426
|
-
},
|
|
5535
|
+
}, time);
|
|
5427
5536
|
}
|
|
5428
5537
|
}, {
|
|
5429
5538
|
key: "onBlur",
|
|
5430
5539
|
value: function onBlur() {
|
|
5431
|
-
var
|
|
5432
|
-
if (!this.isActive) {
|
|
5540
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$ignorePaused = _ref.ignorePaused, ignorePaused = _ref$ignorePaused === void 0 ? false : _ref$ignorePaused;
|
|
5541
|
+
if (!this.isActive || this.innerStates.isActiveLocked) {
|
|
5433
5542
|
return;
|
|
5434
5543
|
}
|
|
5435
5544
|
var closePauseVideoFocus = this.config.closePauseVideoFocus;
|
|
@@ -5552,7 +5661,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5552
5661
|
}, {
|
|
5553
5662
|
key: "onTimeupdate",
|
|
5554
5663
|
value: function onTimeupdate() {
|
|
5555
|
-
!this._videoHeight && this.resize();
|
|
5664
|
+
!this._videoHeight && this.media.videoHeight && this.resize();
|
|
5556
5665
|
if ((this.waitTimer || this.hasClass(STATE_CLASS.LOADING)) && this.media.readyState > 2) {
|
|
5557
5666
|
this.removeClass(STATE_CLASS.LOADING);
|
|
5558
5667
|
util.clearTimeout(this, this.waitTimer);
|
|
@@ -5627,8 +5736,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5627
5736
|
key: "resizePosition",
|
|
5628
5737
|
value: function resizePosition() {
|
|
5629
5738
|
var _this$videoPos = this.videoPos, rotate = _this$videoPos.rotate, vy = _this$videoPos.vy, vx = _this$videoPos.vx, h = _this$videoPos.h, w = _this$videoPos.w;
|
|
5739
|
+
if (rotate < 0 && !vy && !vx) {
|
|
5740
|
+
return;
|
|
5741
|
+
}
|
|
5630
5742
|
var _pi = this.videoPos._pi;
|
|
5631
|
-
if (!_pi) {
|
|
5743
|
+
if (!_pi && this.media.videoHeight) {
|
|
5632
5744
|
_pi = this.media.videoWidth / this.media.videoHeight * 100;
|
|
5633
5745
|
}
|
|
5634
5746
|
if (!_pi) {
|
|
@@ -5728,9 +5840,14 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5728
5840
|
if (!this.media) {
|
|
5729
5841
|
return;
|
|
5730
5842
|
}
|
|
5843
|
+
var containerSize = this.root.getBoundingClientRect();
|
|
5844
|
+
this.sizeInfo.width = containerSize.width;
|
|
5845
|
+
this.sizeInfo.height = containerSize.height;
|
|
5846
|
+
this.sizeInfo.left = containerSize.left;
|
|
5847
|
+
this.sizeInfo.top = containerSize.top;
|
|
5731
5848
|
var _this$media = this.media, videoWidth = _this$media.videoWidth, videoHeight = _this$media.videoHeight;
|
|
5732
5849
|
var _this$config6 = this.config, fitVideoSize = _this$config6.fitVideoSize, videoFillMode = _this$config6.videoFillMode;
|
|
5733
|
-
if (videoFillMode === "fill" || videoFillMode === "cover") {
|
|
5850
|
+
if (videoFillMode === "fill" || videoFillMode === "cover" || videoFillMode === "contain") {
|
|
5734
5851
|
this.setAttribute("data-xgfill", videoFillMode);
|
|
5735
5852
|
}
|
|
5736
5853
|
if (!videoHeight || !videoWidth) {
|
|
@@ -5738,7 +5855,6 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5738
5855
|
}
|
|
5739
5856
|
this._videoHeight = videoHeight;
|
|
5740
5857
|
this._videoWidth = videoWidth;
|
|
5741
|
-
var containerSize = this.root.getBoundingClientRect();
|
|
5742
5858
|
var controlsHeight = this.controls && this.innerContainer ? this.controls.root.getBoundingClientRect().height : 0;
|
|
5743
5859
|
var width = containerSize.width;
|
|
5744
5860
|
var height = containerSize.height - controlsHeight;
|
|
@@ -5793,6 +5909,14 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5793
5909
|
XG_DEBUG.logInfo("setState", "state from:".concat(STATE_ARRAY[this.state], " to:").concat(STATE_ARRAY[newState]));
|
|
5794
5910
|
this._state = newState;
|
|
5795
5911
|
}
|
|
5912
|
+
}, {
|
|
5913
|
+
key: "preProcessUrl",
|
|
5914
|
+
value: function preProcessUrl(url, ext) {
|
|
5915
|
+
var preProcessUrl2 = this.config.preProcessUrl;
|
|
5916
|
+
return !util.isBlob(url) && preProcessUrl2 && typeof preProcessUrl2 === "function" ? preProcessUrl2(url, ext) : {
|
|
5917
|
+
url
|
|
5918
|
+
};
|
|
5919
|
+
}
|
|
5796
5920
|
}, {
|
|
5797
5921
|
key: "state",
|
|
5798
5922
|
get: function get() {
|
|
@@ -5966,9 +6090,8 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
5966
6090
|
}, {
|
|
5967
6091
|
key: "cumulateTime",
|
|
5968
6092
|
get: function get() {
|
|
5969
|
-
var _accPlayed = this._accPlayed;
|
|
5970
|
-
|
|
5971
|
-
return _accPlayed.acc;
|
|
6093
|
+
var _this$_accPlayed = this._accPlayed, acc = _this$_accPlayed.acc, t = _this$_accPlayed.t;
|
|
6094
|
+
return t ? (/* @__PURE__ */ new Date()).getTime() - t + acc : acc;
|
|
5972
6095
|
}
|
|
5973
6096
|
}, {
|
|
5974
6097
|
key: "zoom",
|
|
@@ -6007,6 +6130,22 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
|
|
|
6007
6130
|
set: function set(val) {
|
|
6008
6131
|
REAL_TIME_SPEED = val;
|
|
6009
6132
|
}
|
|
6133
|
+
}, {
|
|
6134
|
+
key: "offsetCurrentTime",
|
|
6135
|
+
get: function get() {
|
|
6136
|
+
return this._offsetInfo.currentTime || 0;
|
|
6137
|
+
},
|
|
6138
|
+
set: function set(val) {
|
|
6139
|
+
this._offsetInfo.currentTime = val;
|
|
6140
|
+
}
|
|
6141
|
+
}, {
|
|
6142
|
+
key: "offsetDuration",
|
|
6143
|
+
get: function get() {
|
|
6144
|
+
return this._offsetInfo.duration || 0;
|
|
6145
|
+
},
|
|
6146
|
+
set: function set(val) {
|
|
6147
|
+
this._offsetInfo.duration = val || 0;
|
|
6148
|
+
}
|
|
6010
6149
|
}, {
|
|
6011
6150
|
key: "hook",
|
|
6012
6151
|
value: function hook$1(hookName, handler) {
|
|
@@ -7652,10 +7791,56 @@ function getDefaultConfig() {
|
|
|
7652
7791
|
var Touche = /* @__PURE__ */ function() {
|
|
7653
7792
|
function Touche2(dom) {
|
|
7654
7793
|
var _this = this;
|
|
7655
|
-
var
|
|
7794
|
+
var _config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
7656
7795
|
eventType: "touch"
|
|
7657
7796
|
};
|
|
7658
7797
|
_classCallCheck(this, Touche2);
|
|
7798
|
+
_defineProperty(this, "onTouchStart", function(e) {
|
|
7799
|
+
var _pos = _this._pos, root = _this.root;
|
|
7800
|
+
var touch = getTouch(e.touches);
|
|
7801
|
+
_pos.x = touch ? parseInt(touch.pageX, 10) : e.pageX;
|
|
7802
|
+
_pos.y = touch ? parseInt(touch.pageX, 10) : e.pageX;
|
|
7803
|
+
_pos.start = true;
|
|
7804
|
+
_this.__setPress(e);
|
|
7805
|
+
root.addEventListener(_this.events.end, _this.onTouchEnd);
|
|
7806
|
+
root.addEventListener(_this.events.cancel, _this.onTouchCancel);
|
|
7807
|
+
root.addEventListener(_this.events.move, _this.onTouchMove);
|
|
7808
|
+
_this.trigger(EVENTS.TOUCH_START, e);
|
|
7809
|
+
});
|
|
7810
|
+
_defineProperty(this, "onTouchCancel", function(e) {
|
|
7811
|
+
_this.onTouchEnd(e);
|
|
7812
|
+
});
|
|
7813
|
+
_defineProperty(this, "onTouchEnd", function(e) {
|
|
7814
|
+
var _pos = _this._pos, root = _this.root;
|
|
7815
|
+
_this.__clearPress();
|
|
7816
|
+
root.removeEventListener(_this.events.cancel, _this.onTouchCancel);
|
|
7817
|
+
root.removeEventListener(_this.events.end, _this.onTouchEnd);
|
|
7818
|
+
root.removeEventListener(_this.events.move, _this.onTouchMove);
|
|
7819
|
+
e.moving = _pos.moving;
|
|
7820
|
+
e.press = _pos.press;
|
|
7821
|
+
_pos.press && _this.trigger(EVENTS.PRESS_END, e);
|
|
7822
|
+
_this.trigger(EVENTS.TOUCH_END, e);
|
|
7823
|
+
!_pos.press && !_pos.moving && _this.__setDb(e);
|
|
7824
|
+
_pos.press = false;
|
|
7825
|
+
_pos.start = false;
|
|
7826
|
+
_pos.moving = false;
|
|
7827
|
+
});
|
|
7828
|
+
_defineProperty(this, "onTouchMove", function(e) {
|
|
7829
|
+
var _pos = _this._pos, config = _this.config;
|
|
7830
|
+
var touch = getTouch(e.touches);
|
|
7831
|
+
var x = touch ? parseInt(touch.pageX, 10) : e.pageX;
|
|
7832
|
+
var y = touch ? parseInt(touch.pageY, 10) : e.pageX;
|
|
7833
|
+
var diffx = x - _pos.x;
|
|
7834
|
+
var diffy = y - _pos.y;
|
|
7835
|
+
if (Math.abs(diffy) < config.miniStep && Math.abs(diffx) < config.miniStep) {
|
|
7836
|
+
return;
|
|
7837
|
+
}
|
|
7838
|
+
_this.__clearPress();
|
|
7839
|
+
_pos.press && _this.trigger(EVENTS.PRESS_END, e);
|
|
7840
|
+
_pos.press = false;
|
|
7841
|
+
_pos.moving = true;
|
|
7842
|
+
_this.trigger(EVENTS.TOUCH_MOVE, e);
|
|
7843
|
+
});
|
|
7659
7844
|
this._pos = {
|
|
7660
7845
|
moving: false,
|
|
7661
7846
|
start: false,
|
|
@@ -7663,11 +7848,11 @@ var Touche = /* @__PURE__ */ function() {
|
|
|
7663
7848
|
y: 0
|
|
7664
7849
|
};
|
|
7665
7850
|
this.config = getDefaultConfig();
|
|
7666
|
-
Object.keys(
|
|
7667
|
-
_this.config[key] =
|
|
7851
|
+
Object.keys(_config).map(function(key) {
|
|
7852
|
+
_this.config[key] = _config[key];
|
|
7668
7853
|
});
|
|
7669
7854
|
this.root = dom;
|
|
7670
|
-
this.events =
|
|
7855
|
+
this.events = _config.eventType === "mouse" ? MOUSES : TOUCHS;
|
|
7671
7856
|
this.pressIntrvalId = null;
|
|
7672
7857
|
this.dbIntrvalId = null;
|
|
7673
7858
|
this.__handlers = {};
|
|
@@ -7676,10 +7861,6 @@ var Touche = /* @__PURE__ */ function() {
|
|
|
7676
7861
|
_createClass(Touche2, [{
|
|
7677
7862
|
key: "_initEvent",
|
|
7678
7863
|
value: function _initEvent() {
|
|
7679
|
-
this.onTouchStart = this.onTouchStart.bind(this);
|
|
7680
|
-
this.onTouchMove = this.onTouchMove.bind(this);
|
|
7681
|
-
this.onTouchEnd = this.onTouchEnd.bind(this);
|
|
7682
|
-
this.onTouchCancel = this.onTouchCancel.bind(this);
|
|
7683
7864
|
this.root.addEventListener(this.events.start, this.onTouchStart);
|
|
7684
7865
|
}
|
|
7685
7866
|
}, {
|
|
@@ -7765,60 +7946,6 @@ var Touche = /* @__PURE__ */ function() {
|
|
|
7765
7946
|
}
|
|
7766
7947
|
});
|
|
7767
7948
|
}
|
|
7768
|
-
}, {
|
|
7769
|
-
key: "onTouchStart",
|
|
7770
|
-
value: function onTouchStart(e) {
|
|
7771
|
-
var _pos = this._pos, root = this.root;
|
|
7772
|
-
var touch = getTouch(e.touches);
|
|
7773
|
-
_pos.x = touch ? parseInt(touch.pageX, 10) : e.pageX;
|
|
7774
|
-
_pos.y = touch ? parseInt(touch.pageX, 10) : e.pageX;
|
|
7775
|
-
_pos.start = true;
|
|
7776
|
-
this.__setPress(e);
|
|
7777
|
-
root.addEventListener(this.events.end, this.onTouchEnd);
|
|
7778
|
-
root.addEventListener(this.events.cancel, this.onTouchCancel);
|
|
7779
|
-
root.addEventListener(this.events.move, this.onTouchMove);
|
|
7780
|
-
this.trigger(EVENTS.TOUCH_START, e);
|
|
7781
|
-
}
|
|
7782
|
-
}, {
|
|
7783
|
-
key: "onTouchCancel",
|
|
7784
|
-
value: function onTouchCancel(e) {
|
|
7785
|
-
this.onTouchEnd(e);
|
|
7786
|
-
}
|
|
7787
|
-
}, {
|
|
7788
|
-
key: "onTouchEnd",
|
|
7789
|
-
value: function onTouchEnd(e) {
|
|
7790
|
-
var _pos = this._pos, root = this.root;
|
|
7791
|
-
this.__clearPress();
|
|
7792
|
-
root.removeEventListener(this.events.cancel, this.onTouchCancel);
|
|
7793
|
-
root.removeEventListener(this.events.end, this.onTouchEnd);
|
|
7794
|
-
root.removeEventListener(this.events.move, this.onTouchMove);
|
|
7795
|
-
e.moving = _pos.moving;
|
|
7796
|
-
e.press = _pos.press;
|
|
7797
|
-
_pos.press && this.trigger(EVENTS.PRESS_END, e);
|
|
7798
|
-
this.trigger(EVENTS.TOUCH_END, e);
|
|
7799
|
-
!_pos.press && !_pos.moving && this.__setDb(e);
|
|
7800
|
-
_pos.press = false;
|
|
7801
|
-
_pos.start = false;
|
|
7802
|
-
_pos.moving = false;
|
|
7803
|
-
}
|
|
7804
|
-
}, {
|
|
7805
|
-
key: "onTouchMove",
|
|
7806
|
-
value: function onTouchMove(e) {
|
|
7807
|
-
var _pos = this._pos, config = this.config;
|
|
7808
|
-
var touch = getTouch(e.touches);
|
|
7809
|
-
var x = touch ? parseInt(touch.pageX, 10) : e.pageX;
|
|
7810
|
-
var y = touch ? parseInt(touch.pageY, 10) : e.pageX;
|
|
7811
|
-
var diffx = x - _pos.x;
|
|
7812
|
-
var diffy = y - _pos.y;
|
|
7813
|
-
if (Math.abs(diffy) < config.miniStep && Math.abs(diffx) < config.miniStep) {
|
|
7814
|
-
return;
|
|
7815
|
-
}
|
|
7816
|
-
this.__clearPress();
|
|
7817
|
-
_pos.press && this.trigger(EVENTS.PRESS_END, e);
|
|
7818
|
-
_pos.press = false;
|
|
7819
|
-
_pos.moving = true;
|
|
7820
|
-
this.trigger(EVENTS.TOUCH_MOVE, e);
|
|
7821
|
-
}
|
|
7822
7949
|
}, {
|
|
7823
7950
|
key: "destroy",
|
|
7824
7951
|
value: function destroy2() {
|
|
@@ -7828,8 +7955,8 @@ var Touche = /* @__PURE__ */ function() {
|
|
|
7828
7955
|
touchmove: "onTouchMove",
|
|
7829
7956
|
touchstart: "onTouchStart"
|
|
7830
7957
|
};
|
|
7831
|
-
Object.keys(map).
|
|
7832
|
-
_this4.root.removeEventListener(
|
|
7958
|
+
Object.keys(map).forEach(function(key) {
|
|
7959
|
+
_this4.root.removeEventListener(key, _this4[map[key]]);
|
|
7833
7960
|
});
|
|
7834
7961
|
}
|
|
7835
7962
|
}]);
|
|
@@ -8480,38 +8607,61 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8480
8607
|
}
|
|
8481
8608
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
8482
8609
|
_defineProperty(_assertThisInitialized(_this), "onBodyKeyDown", function(event) {
|
|
8483
|
-
|
|
8484
|
-
if (!_this.player || !_this.player.isUserActive && !_this.config.isIgnoreUserActive) {
|
|
8610
|
+
if (!_this.player) {
|
|
8485
8611
|
return;
|
|
8486
8612
|
}
|
|
8487
|
-
|
|
8613
|
+
var e = event || window.event;
|
|
8614
|
+
var keyCode = e.keyCode;
|
|
8615
|
+
var _assertThisInitialize = _assertThisInitialized(_this), _keyState = _assertThisInitialize._keyState, player = _assertThisInitialize.player;
|
|
8616
|
+
var _this$config = _this.config, disable = _this$config.disable, disableBodyTrigger = _this$config.disableBodyTrigger, isIgnoreUserActive = _this$config.isIgnoreUserActive;
|
|
8617
|
+
if (disable || disableBodyTrigger || !player.isUserActive && !isIgnoreUserActive || isDisableTag(e.target) || !_this.checkIsVisible() || e.metaKey || e.altKey || e.ctrlKey) {
|
|
8618
|
+
_keyState.isBodyKeyDown = false;
|
|
8488
8619
|
return;
|
|
8489
8620
|
}
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8621
|
+
if (!event.repeat && !_keyState.isKeyDown) {
|
|
8622
|
+
if ((e.target === document.body || _this.config.isGlobalTrigger && !isDisableTag(e.target)) && _this.checkCode(keyCode, true)) {
|
|
8623
|
+
_keyState.isBodyKeyDown = true;
|
|
8624
|
+
}
|
|
8625
|
+
document.addEventListener("keyup", _this.onBodyKeyUp);
|
|
8495
8626
|
}
|
|
8496
|
-
|
|
8627
|
+
_keyState.isBodyKeyDown && _this.handleKeyDown(e);
|
|
8497
8628
|
});
|
|
8498
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
8499
|
-
|
|
8500
|
-
if (_this.config.disable || _this.config.disableRootTrigger || e.metaKey || e.altKey || e.ctrlKey) {
|
|
8629
|
+
_defineProperty(_assertThisInitialized(_this), "onBodyKeyUp", function(event) {
|
|
8630
|
+
if (!_this.player) {
|
|
8501
8631
|
return;
|
|
8502
8632
|
}
|
|
8503
|
-
|
|
8633
|
+
document.removeEventListener("keyup", _this.onBodyKeyUp);
|
|
8634
|
+
_this.handleKeyUp(event);
|
|
8635
|
+
});
|
|
8636
|
+
_defineProperty(_assertThisInitialized(_this), "onKeydown", function(event) {
|
|
8637
|
+
if (!_this.player) {
|
|
8504
8638
|
return;
|
|
8505
8639
|
}
|
|
8506
|
-
|
|
8640
|
+
var e = event || window.event;
|
|
8641
|
+
var _assertThisInitialize2 = _assertThisInitialized(_this), _keyState = _assertThisInitialize2._keyState;
|
|
8642
|
+
if (!e.repeat) {
|
|
8643
|
+
if (_this.config.disable || _this.config.disableRootTrigger || e.metaKey || e.altKey || e.ctrlKey) {
|
|
8644
|
+
return;
|
|
8645
|
+
}
|
|
8646
|
+
if (!_this.player.isUserActive && !_this.config.isIgnoreUserActive) {
|
|
8647
|
+
return;
|
|
8648
|
+
}
|
|
8649
|
+
if (e && (e.keyCode === 37 || _this.checkCode(e.keyCode)) && (e.target === _this.player.root || e.target === _this.player.video || e.target === _this.player.controls.el)) {
|
|
8650
|
+
_keyState.isKeyDown = true;
|
|
8651
|
+
}
|
|
8652
|
+
_this.player.root.addEventListener("keyup", _this.onKeyup);
|
|
8653
|
+
}
|
|
8654
|
+
if (!_keyState.isKeyDown) {
|
|
8507
8655
|
return;
|
|
8508
8656
|
}
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8657
|
+
_this.handleKeyDown(e);
|
|
8658
|
+
});
|
|
8659
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyup", function(event) {
|
|
8660
|
+
if (!_this.player) {
|
|
8661
|
+
return;
|
|
8513
8662
|
}
|
|
8514
|
-
_this.
|
|
8663
|
+
_this.player.root.removeEventListener("keyup", _this.onKeyup);
|
|
8664
|
+
_this.handleKeyUp(event);
|
|
8515
8665
|
});
|
|
8516
8666
|
return _this;
|
|
8517
8667
|
}
|
|
@@ -8525,7 +8675,7 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8525
8675
|
if (!_this2.keyCodeMap[key]) {
|
|
8526
8676
|
_this2.keyCodeMap[key] = extendkeyCodeMap[key];
|
|
8527
8677
|
} else {
|
|
8528
|
-
["keyCode", "action", "disable", "isBodyTarget"].map(function(key1) {
|
|
8678
|
+
["keyCode", "action", "disable", "pressAction", "disablePress", "isBodyTarget"].map(function(key1) {
|
|
8529
8679
|
extendkeyCodeMap[key][key1] && (_this2.keyCodeMap[key][key1] = extendkeyCodeMap[key][key1]);
|
|
8530
8680
|
});
|
|
8531
8681
|
}
|
|
@@ -8545,37 +8695,51 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8545
8695
|
keyCode: 32,
|
|
8546
8696
|
action: "playPause",
|
|
8547
8697
|
disable: false,
|
|
8698
|
+
disablePress: false,
|
|
8548
8699
|
noBodyTarget: false
|
|
8549
8700
|
},
|
|
8550
8701
|
up: {
|
|
8551
8702
|
keyCode: 38,
|
|
8552
8703
|
action: "upVolume",
|
|
8553
8704
|
disable: false,
|
|
8705
|
+
disablePress: false,
|
|
8554
8706
|
noBodyTarget: true
|
|
8555
8707
|
},
|
|
8556
8708
|
down: {
|
|
8557
8709
|
keyCode: 40,
|
|
8558
8710
|
action: "downVolume",
|
|
8559
8711
|
disable: false,
|
|
8712
|
+
disablePress: false,
|
|
8560
8713
|
noBodyTarget: true
|
|
8561
8714
|
},
|
|
8562
8715
|
left: {
|
|
8563
8716
|
keyCode: 37,
|
|
8564
8717
|
action: "seekBack",
|
|
8718
|
+
disablePress: false,
|
|
8565
8719
|
disable: false
|
|
8566
8720
|
},
|
|
8567
8721
|
right: {
|
|
8568
8722
|
keyCode: 39,
|
|
8569
8723
|
action: "seek",
|
|
8724
|
+
pressAction: "changePlaybackRate",
|
|
8725
|
+
disablePress: false,
|
|
8570
8726
|
disable: false
|
|
8571
8727
|
},
|
|
8572
8728
|
esc: {
|
|
8573
8729
|
keyCode: 27,
|
|
8574
8730
|
action: "exitFullscreen",
|
|
8731
|
+
disablePress: true,
|
|
8575
8732
|
disable: false
|
|
8576
8733
|
}
|
|
8577
8734
|
};
|
|
8578
8735
|
this.mergekeyCodeMap();
|
|
8736
|
+
this._keyState = {
|
|
8737
|
+
isKeyDown: false,
|
|
8738
|
+
isBodyKeyDown: false,
|
|
8739
|
+
isPress: false,
|
|
8740
|
+
tt: 0,
|
|
8741
|
+
playbackRate: 0
|
|
8742
|
+
};
|
|
8579
8743
|
this.player.root.addEventListener("keydown", this.onKeydown);
|
|
8580
8744
|
document.addEventListener("keydown", this.onBodyKeyDown);
|
|
8581
8745
|
}
|
|
@@ -8609,6 +8773,9 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8609
8773
|
key: "downVolume",
|
|
8610
8774
|
value: function downVolume(event) {
|
|
8611
8775
|
var player = this.player;
|
|
8776
|
+
if (player.volume <= 0) {
|
|
8777
|
+
return;
|
|
8778
|
+
}
|
|
8612
8779
|
var val = parseFloat((player.volume - 0.1).toFixed(1));
|
|
8613
8780
|
var props = {
|
|
8614
8781
|
volume: {
|
|
@@ -8629,6 +8796,9 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8629
8796
|
key: "upVolume",
|
|
8630
8797
|
value: function upVolume(event) {
|
|
8631
8798
|
var player = this.player;
|
|
8799
|
+
if (player.volume >= 1) {
|
|
8800
|
+
return;
|
|
8801
|
+
}
|
|
8632
8802
|
var val = parseFloat((player.volume + 0.1).toFixed(1));
|
|
8633
8803
|
var props = {
|
|
8634
8804
|
volume: {
|
|
@@ -8648,42 +8818,57 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8648
8818
|
}, {
|
|
8649
8819
|
key: "seek",
|
|
8650
8820
|
value: function seek(event) {
|
|
8651
|
-
var _this$player = this.player, currentTime = _this$player.currentTime, duration = _this$player.duration;
|
|
8652
|
-
var _time = currentTime;
|
|
8653
|
-
|
|
8654
|
-
|
|
8821
|
+
var _this$player = this.player, currentTime = _this$player.currentTime, offsetCurrentTime = _this$player.offsetCurrentTime, duration = _this$player.duration, offsetDuration = _this$player.offsetDuration, timeSegments = _this$player.timeSegments;
|
|
8822
|
+
var _time = offsetCurrentTime > -1 ? offsetCurrentTime : currentTime;
|
|
8823
|
+
var _duration = offsetDuration || duration;
|
|
8824
|
+
var _step = event.repeat && this.seekStep >= 4 ? parseInt(this.seekStep / 2, 10) : this.seekStep;
|
|
8825
|
+
if (_time + _step <= _duration) {
|
|
8826
|
+
_time = _time + _step;
|
|
8655
8827
|
} else {
|
|
8656
|
-
_time =
|
|
8828
|
+
_time = _duration;
|
|
8657
8829
|
}
|
|
8830
|
+
var _seekTime = util.getCurrentTimeByOffset(_time, timeSegments);
|
|
8658
8831
|
var props = {
|
|
8659
8832
|
currentTime: {
|
|
8660
8833
|
from: currentTime,
|
|
8661
|
-
to:
|
|
8834
|
+
to: _seekTime
|
|
8662
8835
|
}
|
|
8663
8836
|
};
|
|
8664
8837
|
this.emitUserAction(event, "seek", {
|
|
8665
8838
|
props
|
|
8666
8839
|
});
|
|
8667
|
-
this.player.currentTime =
|
|
8840
|
+
this.player.currentTime = _seekTime;
|
|
8668
8841
|
}
|
|
8669
8842
|
}, {
|
|
8670
8843
|
key: "seekBack",
|
|
8671
8844
|
value: function seekBack(event) {
|
|
8672
|
-
var
|
|
8673
|
-
var
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8845
|
+
var _this$player2 = this.player, currentTime = _this$player2.currentTime, offsetCurrentTime = _this$player2.offsetCurrentTime, timeSegments = _this$player2.timeSegments;
|
|
8846
|
+
var _step = event.repeat ? parseInt(this.seekStep / 2, 10) : this.seekStep;
|
|
8847
|
+
var _time = offsetCurrentTime > -1 ? offsetCurrentTime : currentTime;
|
|
8848
|
+
var _seekTime = _time - _step;
|
|
8849
|
+
if (_seekTime < 0) {
|
|
8850
|
+
_seekTime = 0;
|
|
8851
|
+
}
|
|
8852
|
+
_seekTime = util.getCurrentTimeByOffset(_seekTime, timeSegments);
|
|
8677
8853
|
var props = {
|
|
8678
8854
|
currentTime: {
|
|
8679
8855
|
from: currentTime,
|
|
8680
|
-
to:
|
|
8856
|
+
to: _seekTime
|
|
8681
8857
|
}
|
|
8682
8858
|
};
|
|
8683
8859
|
this.emitUserAction(event, "seek", {
|
|
8684
8860
|
props
|
|
8685
8861
|
});
|
|
8686
|
-
this.player.currentTime =
|
|
8862
|
+
this.player.currentTime = _seekTime;
|
|
8863
|
+
}
|
|
8864
|
+
}, {
|
|
8865
|
+
key: "changePlaybackRate",
|
|
8866
|
+
value: function changePlaybackRate(event) {
|
|
8867
|
+
var _keyState = this._keyState, config = this.config, player = this.player;
|
|
8868
|
+
if (_keyState.playbackRate === 0) {
|
|
8869
|
+
_keyState.playbackRate = player.playbackRate;
|
|
8870
|
+
player.playbackRate = config.playbackRate;
|
|
8871
|
+
}
|
|
8687
8872
|
}
|
|
8688
8873
|
}, {
|
|
8689
8874
|
key: "playPause",
|
|
@@ -8721,32 +8906,66 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8721
8906
|
player.exitCssFullscreen();
|
|
8722
8907
|
}
|
|
8723
8908
|
}
|
|
8909
|
+
}, {
|
|
8910
|
+
key: "handleKeyDown",
|
|
8911
|
+
value: function handleKeyDown(e) {
|
|
8912
|
+
var _keyState = this._keyState;
|
|
8913
|
+
if (e.repeat) {
|
|
8914
|
+
_keyState.isPress = true;
|
|
8915
|
+
var _t = Date.now();
|
|
8916
|
+
if (_t - _keyState.tt < 200) {
|
|
8917
|
+
return;
|
|
8918
|
+
}
|
|
8919
|
+
_keyState.tt = _t;
|
|
8920
|
+
}
|
|
8921
|
+
preventDefault(e);
|
|
8922
|
+
this.handleKeyCode(e.keyCode, e, _keyState.isPress);
|
|
8923
|
+
}
|
|
8924
|
+
}, {
|
|
8925
|
+
key: "handleKeyUp",
|
|
8926
|
+
value: function handleKeyUp(e) {
|
|
8927
|
+
var _keyState = this._keyState;
|
|
8928
|
+
if (_keyState.playbackRate > 0) {
|
|
8929
|
+
this.player.playbackRate = _keyState.playbackRate;
|
|
8930
|
+
_keyState.playbackRate = 0;
|
|
8931
|
+
}
|
|
8932
|
+
_keyState.isKeyDown = false;
|
|
8933
|
+
_keyState.isPress = false;
|
|
8934
|
+
_keyState.tt = 0;
|
|
8935
|
+
}
|
|
8724
8936
|
}, {
|
|
8725
8937
|
key: "handleKeyCode",
|
|
8726
|
-
value: function handleKeyCode(curKeyCode, event) {
|
|
8727
|
-
var
|
|
8728
|
-
|
|
8729
|
-
var
|
|
8730
|
-
if (keyCode === curKeyCode
|
|
8731
|
-
if (
|
|
8732
|
-
action
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8938
|
+
value: function handleKeyCode(curKeyCode, event, isPress) {
|
|
8939
|
+
var arr = Object.keys(this.keyCodeMap);
|
|
8940
|
+
for (var i = 0; i < arr.length; i++) {
|
|
8941
|
+
var _this$keyCodeMap$arr$ = this.keyCodeMap[arr[i]], action = _this$keyCodeMap$arr$.action, keyCode = _this$keyCodeMap$arr$.keyCode, disable = _this$keyCodeMap$arr$.disable, pressAction = _this$keyCodeMap$arr$.pressAction, disablePress = _this$keyCodeMap$arr$.disablePress;
|
|
8942
|
+
if (keyCode === curKeyCode) {
|
|
8943
|
+
if (!disable && !(isPress && disablePress)) {
|
|
8944
|
+
var _action = !isPress ? action : pressAction || action;
|
|
8945
|
+
if (typeof _action === "function") {
|
|
8946
|
+
action(event, this.player, isPress);
|
|
8947
|
+
} else if (typeof _action === "string") {
|
|
8948
|
+
if (typeof this[_action] === "function") {
|
|
8949
|
+
this[_action](event, this.player, isPress);
|
|
8950
|
+
}
|
|
8736
8951
|
}
|
|
8952
|
+
this.emit(SHORTCUT, _objectSpread2({
|
|
8953
|
+
key: arr[i],
|
|
8954
|
+
target: event.target,
|
|
8955
|
+
isPress
|
|
8956
|
+
}, this.keyCodeMap[arr[i]]));
|
|
8737
8957
|
}
|
|
8738
|
-
|
|
8739
|
-
key,
|
|
8740
|
-
target: event.target
|
|
8741
|
-
}, _this4.keyCodeMap[key]));
|
|
8958
|
+
break;
|
|
8742
8959
|
}
|
|
8743
|
-
}
|
|
8960
|
+
}
|
|
8744
8961
|
}
|
|
8745
8962
|
}, {
|
|
8746
8963
|
key: "destroy",
|
|
8747
8964
|
value: function destroy2() {
|
|
8748
8965
|
this.player.root.removeEventListener("keydown", this.onKeydown);
|
|
8749
8966
|
document.removeEventListener("keydown", this.onBodyKeyDown);
|
|
8967
|
+
this.player.root.removeEventListener("keyup", this.onKeyup);
|
|
8968
|
+
document.removeEventListener("keyup", this.onBodyKeyUp);
|
|
8750
8969
|
}
|
|
8751
8970
|
}, {
|
|
8752
8971
|
key: "disable",
|
|
@@ -8768,12 +8987,13 @@ var Keyboard = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
8768
8987
|
get: function get() {
|
|
8769
8988
|
return {
|
|
8770
8989
|
seekStep: 10,
|
|
8771
|
-
checkVisible:
|
|
8990
|
+
checkVisible: false,
|
|
8772
8991
|
disableBodyTrigger: false,
|
|
8773
8992
|
disableRootTrigger: false,
|
|
8774
8993
|
isGlobalTrigger: false,
|
|
8775
8994
|
keyCodeMap: {},
|
|
8776
8995
|
disable: false,
|
|
8996
|
+
playbackRate: 2,
|
|
8777
8997
|
isIgnoreUserActive: false
|
|
8778
8998
|
};
|
|
8779
8999
|
}
|
|
@@ -10066,6 +10286,9 @@ class Definition {
|
|
|
10066
10286
|
get url() {
|
|
10067
10287
|
return this._currentUrlRef.url;
|
|
10068
10288
|
}
|
|
10289
|
+
set url(url) {
|
|
10290
|
+
this._currentUrlRef.url = url;
|
|
10291
|
+
}
|
|
10069
10292
|
next() {
|
|
10070
10293
|
const next = this._currentUrlRef.next;
|
|
10071
10294
|
/* istanbul ignore next -- @preserve */
|
|
@@ -10143,7 +10366,6 @@ class SourceManager {
|
|
|
10143
10366
|
__publicField(this, "defaultSource");
|
|
10144
10367
|
__publicField(this, "defaultDefinition");
|
|
10145
10368
|
__publicField(this, "maxFallbackRound");
|
|
10146
|
-
__publicField(this, "_prepareList", []);
|
|
10147
10369
|
__publicField(this, "_currentDefinition");
|
|
10148
10370
|
__publicField(this, "_sources");
|
|
10149
10371
|
__publicField(this, "_fallbackCount", 0);
|
|
@@ -10178,6 +10400,11 @@ class SourceManager {
|
|
|
10178
10400
|
var _a;
|
|
10179
10401
|
return (_a = this.definition) == null ? void 0 : _a.url;
|
|
10180
10402
|
}
|
|
10403
|
+
set url(url) {
|
|
10404
|
+
if (this.definition) {
|
|
10405
|
+
this.definition.url = url;
|
|
10406
|
+
}
|
|
10407
|
+
}
|
|
10181
10408
|
/**
|
|
10182
10409
|
* 以给定的参数搜索源和对应清晰度。`source` 和 `definition`
|
|
10183
10410
|
* 都是可选的,当未指定时,使用当前的 {@link SourceManager.source}
|
|
@@ -10247,14 +10474,6 @@ class SourceManager {
|
|
|
10247
10474
|
this.resetFallback();
|
|
10248
10475
|
return this;
|
|
10249
10476
|
}
|
|
10250
|
-
registerPrepare(prepare) {
|
|
10251
|
-
this._prepareList.push(prepare);
|
|
10252
|
-
}
|
|
10253
|
-
async prepare(url) {
|
|
10254
|
-
for (const prepare of this._prepareList) {
|
|
10255
|
-
await prepare(url);
|
|
10256
|
-
}
|
|
10257
|
-
}
|
|
10258
10477
|
resetFallback() {
|
|
10259
10478
|
this._fallbackCount = 0;
|
|
10260
10479
|
}
|
|
@@ -11845,9 +12064,7 @@ class DefinitionPlugin extends OptionsIcon {
|
|
|
11845
12064
|
toastPlugin.remove(this._toastId);
|
|
11846
12065
|
}
|
|
11847
12066
|
this._toastId = toastPlugin.toast(
|
|
11848
|
-
`${i18nManager.getText("DEFINITION_SWITCHING")} ${
|
|
11849
|
-
definition.text
|
|
11850
|
-
)) ?? definition.definition} ...`,
|
|
12067
|
+
`${i18nManager.getText("DEFINITION_SWITCHING")} ${definition.showText ?? definition.definition} ...`,
|
|
11851
12068
|
{
|
|
11852
12069
|
duration: 2e3,
|
|
11853
12070
|
closable: true
|
|
@@ -12741,7 +12958,6 @@ class VePlayerBase {
|
|
|
12741
12958
|
veplayer: this
|
|
12742
12959
|
});
|
|
12743
12960
|
this.emit(Events.PLAYER_CREATE_FINISH, this._player);
|
|
12744
|
-
this._sourceManager.registerPrepare((url) => this.prepare(url));
|
|
12745
12961
|
this._errorCallback = (err) => this._handleFallback(err);
|
|
12746
12962
|
this._player.on(ERROR, this._errorCallback);
|
|
12747
12963
|
}
|
|
@@ -12907,7 +13123,7 @@ class VePlayerBase {
|
|
|
12907
13123
|
return;
|
|
12908
13124
|
}
|
|
12909
13125
|
if (!VeI18n.isLangValid(lang)) {
|
|
12910
|
-
const langKeys = VeI18n.langKeys
|
|
13126
|
+
const langKeys = VeI18n.langKeys.join(",");
|
|
12911
13127
|
const message = {
|
|
12912
13128
|
en: `Sorry, we couldn't set the language to ${lang} because it's not currently supported. The list of supported languages includes ${langKeys}.`,
|
|
12913
13129
|
"zh-cn": `不支持当前设置的语言${lang}, 支持的语言有${langKeys}, 请重新设置`
|
|
@@ -12926,7 +13142,7 @@ class VePlayerBase {
|
|
|
12926
13142
|
* @hidden
|
|
12927
13143
|
*/
|
|
12928
13144
|
static async create(options = {}, Constructor) {
|
|
12929
|
-
var _a;
|
|
13145
|
+
var _a, _b, _c;
|
|
12930
13146
|
const sourceManager = new SourceManager({
|
|
12931
13147
|
sources: Source.normalize({
|
|
12932
13148
|
url: options.url,
|
|
@@ -12938,8 +13154,14 @@ class VePlayerBase {
|
|
|
12938
13154
|
defaultDefinition: options.defaultDefinition,
|
|
12939
13155
|
maxFallbackRound: options.maxFallbackRound
|
|
12940
13156
|
});
|
|
13157
|
+
const prepareResult = await ((_a = options == null ? void 0 : options.preparePlugins) == null ? void 0 : _a.call(
|
|
13158
|
+
options,
|
|
13159
|
+
sourceManager.url ?? ""
|
|
13160
|
+
));
|
|
13161
|
+
if ((_b = prepareResult == null ? void 0 : prepareResult.options) == null ? void 0 : _b.url) {
|
|
13162
|
+
sourceManager.url = (_c = prepareResult == null ? void 0 : prepareResult.options) == null ? void 0 : _c.url;
|
|
13163
|
+
}
|
|
12941
13164
|
options.url = sourceManager.url;
|
|
12942
|
-
const prepareResult = await ((_a = options == null ? void 0 : options.preparePlugins) == null ? void 0 : _a.call(options, options.url ?? ""));
|
|
12943
13165
|
return new (Constructor ?? VePlayerBase)({
|
|
12944
13166
|
...options,
|
|
12945
13167
|
prepareResult,
|
|
@@ -12954,7 +13176,6 @@ class VePlayerBase {
|
|
|
12954
13176
|
async switch(target, options) {
|
|
12955
13177
|
var _a, _b;
|
|
12956
13178
|
if (typeof target === "string" && this._sourceManager.sources.length === 1 && ((_b = (_a = this._sourceManager.sources) == null ? void 0 : _a[0].definitions) == null ? void 0 : _b.length) === 1) {
|
|
12957
|
-
this._sourceManager.updateSources(target);
|
|
12958
13179
|
await this._switchUrl(target);
|
|
12959
13180
|
return this._sourceManager.definition;
|
|
12960
13181
|
}
|
|
@@ -13093,7 +13314,7 @@ class VePlayerBase {
|
|
|
13093
13314
|
* @brief 调用此方法进入系统全屏状态。如果该方法调用的时候处于网页全屏状态会自动退出网页全屏,下发事件 `Events.FULLSCREEN_CHANGE`。
|
|
13094
13315
|
* @param el 全屏作用的 DOM 节点。
|
|
13095
13316
|
*/
|
|
13096
|
-
|
|
13317
|
+
requestFullscreen(el) {
|
|
13097
13318
|
return this._player.getFullscreen(el);
|
|
13098
13319
|
}
|
|
13099
13320
|
/**
|
|
@@ -13107,7 +13328,7 @@ class VePlayerBase {
|
|
|
13107
13328
|
* @brief 调用此方法进入网页样式全屏状态,播放器进入网页全屏,利用 CSS 模拟实现全屏效果。如果该接口调用的时候处于全屏状态,会自动退出全屏,下发事件 `Events.CSS_FULLSCREEN_CHANGE`。
|
|
13108
13329
|
* @param el 全屏作用的 DOM 节点。
|
|
13109
13330
|
*/
|
|
13110
|
-
|
|
13331
|
+
requestCssFullscreen(el) {
|
|
13111
13332
|
return this._player.getCssFullscreen(el);
|
|
13112
13333
|
}
|
|
13113
13334
|
/**
|
|
@@ -13190,9 +13411,12 @@ class VePlayerBase {
|
|
|
13190
13411
|
if (result == null ? void 0 : result.options) {
|
|
13191
13412
|
this._player.setConfig(result.options);
|
|
13192
13413
|
}
|
|
13193
|
-
return
|
|
13194
|
-
|
|
13195
|
-
|
|
13414
|
+
return {
|
|
13415
|
+
plugins: addedPlugins.map((plugin) => {
|
|
13416
|
+
return this._player.registerPlugin(plugin);
|
|
13417
|
+
}),
|
|
13418
|
+
options: result == null ? void 0 : result.options
|
|
13419
|
+
};
|
|
13196
13420
|
}
|
|
13197
13421
|
async _handleFallback(err) {
|
|
13198
13422
|
this._player.addClass(STATE_CLASS.ENTER);
|
|
@@ -13227,7 +13451,10 @@ class VePlayerBase {
|
|
|
13227
13451
|
async _switch(targetDefinition) {
|
|
13228
13452
|
var _a, _b, _c, _d, _e, _f;
|
|
13229
13453
|
const preDefinition = clonedeep(this._sourceManager.definition);
|
|
13230
|
-
const newPlugins = await this.prepare(targetDefinition.url);
|
|
13454
|
+
const { plugins: newPlugins, options } = await this.prepare(targetDefinition.url) || {};
|
|
13455
|
+
if (options == null ? void 0 : options.url) {
|
|
13456
|
+
targetDefinition.url = options == null ? void 0 : options.url;
|
|
13457
|
+
}
|
|
13231
13458
|
this._sourceManager.switch(targetDefinition);
|
|
13232
13459
|
(_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.sources.renderItemList();
|
|
13233
13460
|
(_d = (_c = this._player) == null ? void 0 : _c.plugins) == null ? void 0 : _d.definition.renderItemList();
|
|
@@ -13243,11 +13470,13 @@ class VePlayerBase {
|
|
|
13243
13470
|
}
|
|
13244
13471
|
}
|
|
13245
13472
|
async _switchUrl(url) {
|
|
13246
|
-
const newPlugins = await this.prepare(url);
|
|
13473
|
+
const { plugins: newPlugins, options } = await this.prepare(url) || {};
|
|
13474
|
+
const newUrl = (options == null ? void 0 : options.url) ?? url;
|
|
13475
|
+
this._sourceManager.updateSources(newUrl);
|
|
13247
13476
|
if (newPlugins == null ? void 0 : newPlugins.length) {
|
|
13248
|
-
this._callBeforePlayerInitForUrl(newPlugins,
|
|
13477
|
+
this._callBeforePlayerInitForUrl(newPlugins, newUrl);
|
|
13249
13478
|
} else {
|
|
13250
|
-
const res = this._player.switchURL(
|
|
13479
|
+
const res = this._player.switchURL(newUrl, false);
|
|
13251
13480
|
const curTime = this._player.currentTime;
|
|
13252
13481
|
if (res && res.then) {
|
|
13253
13482
|
return res;
|