@volcengine/veplayer-plugin 2.4.0-rc.4 → 2.4.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/esm/veplayer.plugin.abr.development.js +14994 -0
  2. package/esm/veplayer.plugin.abr.production.js +2 -0
  3. package/esm/veplayer.plugin.drm.development.js +1580 -0
  4. package/esm/veplayer.plugin.drm.production.js +2 -0
  5. package/esm/veplayer.plugin.mp4.development.js +38042 -0
  6. package/esm/veplayer.plugin.mp4.production.js +2 -0
  7. package/esm/veplayer.plugin.rtm.development.js +5790 -0
  8. package/esm/veplayer.plugin.rtm.production.js +2 -0
  9. package/esm/veplayer.plugin.shaka.development.js +15976 -0
  10. package/esm/veplayer.plugin.shaka.production.js +20 -0
  11. package/esm/veplayer.plugin.time.shift.development.css +63 -0
  12. package/esm/veplayer.plugin.time.shift.development.js +339 -0
  13. package/esm/veplayer.plugin.time.shift.production.css +1 -0
  14. package/esm/veplayer.plugin.time.shift.production.js +2 -0
  15. package/esm/veplayer.plugin.xgvideo.development.js +19097 -0
  16. package/esm/veplayer.plugin.xgvideo.production.js +2 -0
  17. package/package.json +1 -1
  18. package/umd/veplayer.plugin.abr.development.js +14996 -0
  19. package/umd/veplayer.plugin.abr.production.js +1 -0
  20. package/umd/veplayer.plugin.drm.development.js +1582 -0
  21. package/umd/veplayer.plugin.drm.production.js +1 -0
  22. package/umd/veplayer.plugin.mp4.development.js +38046 -0
  23. package/umd/veplayer.plugin.mp4.production.js +1 -0
  24. package/umd/veplayer.plugin.rtm.development.js +5792 -0
  25. package/umd/veplayer.plugin.rtm.production.js +1 -0
  26. package/umd/veplayer.plugin.shaka.development.js +15980 -0
  27. package/umd/veplayer.plugin.shaka.production.js +1 -0
  28. package/umd/veplayer.plugin.time.shift.development.css +63 -0
  29. package/umd/veplayer.plugin.time.shift.development.js +342 -0
  30. package/umd/veplayer.plugin.time.shift.production.css +1 -0
  31. package/umd/veplayer.plugin.time.shift.production.js +1 -0
  32. package/umd/veplayer.plugin.xgvideo.development.js +19099 -0
  33. package/umd/veplayer.plugin.xgvideo.production.js +1 -0
@@ -0,0 +1,63 @@
1
+ .xgplayer-shift .xgplayer-shift-progress-point {
2
+ position: absolute;
3
+ top: -30px;
4
+ display: none;
5
+ width: 60px;
6
+ padding: 6px 0;
7
+ color: #fff;
8
+ font-size: 12px;
9
+ line-height: 18px;
10
+ text-align: center;
11
+ background: rgba(0, 0, 0, 0.6);
12
+ border-radius: 2px;
13
+ transform: translateX(-50%);
14
+ }
15
+ .xgplayer-shift.active .xgplayer-shift-progress-point {
16
+ display: block;
17
+ }
18
+ .xgplayer-shift.xgplayer-progress .xgplayer-progress-outer {
19
+ transition: unset;
20
+ }
21
+ .xgplayer-shift.xgplayer-progress .xgplayer-progress-btn {
22
+ width: 16px;
23
+ height: 16px;
24
+ background: #346aff41;
25
+ box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.096);
26
+ }
27
+ .xgplayer-shift.xgplayer-progress .xgplayer-progress-played {
28
+ background: #3469ff;
29
+ }
30
+ .xgplayer-back-live-bt {
31
+ position: absolute;
32
+ bottom: 60px;
33
+ left: 20px;
34
+ display: none;
35
+ align-items: center;
36
+ justify-content: center;
37
+ width: 96px;
38
+ height: 32px;
39
+ color: #fff;
40
+ font-size: 13px;
41
+ background: rgba(0, 0, 0, 0.4);
42
+ border: 1px solid rgba(255, 255, 255, 0.8);
43
+ border-radius: 16px;
44
+ cursor: pointer;
45
+ }
46
+ .xgplayer-back-live-bt:hover {
47
+ background: rgba(0, 0, 0, 0.6);
48
+ }
49
+ .xgplayer-inactive .xgplayer-back-live-bt {
50
+ display: none;
51
+ }
52
+ .xgplayer-mobile .xgplayer-shift {
53
+ margin: 0 8px;
54
+ }
55
+ .xgplayer-mobile .xgplayer-shift .xgplayer-shift-progress-point {
56
+ display: none;
57
+ }
58
+ .xgplayer-mobile .xgplayer-back-live-bt {
59
+ bottom: 40px;
60
+ width: 86px;
61
+ height: 25px;
62
+ font-size: 12px;
63
+ }
@@ -0,0 +1,339 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ const formatTime = function(time) {
8
+ let hour = Math.floor(time / 3600);
9
+ const remainTime = time % 3600;
10
+ let minute = Math.floor(remainTime / 60);
11
+ let second = Math.round(remainTime % 60);
12
+ minute = minute.toString().padStart(2, "0");
13
+ second = second.toString().padStart(2, "0");
14
+ if (hour > 0) {
15
+ hour = hour.toString().padStart(2, "0");
16
+ return `${hour}:${minute}:${second}`;
17
+ }
18
+ return `${minute}:${second}`;
19
+ };
20
+ const addUrlParam = (originUrl, params) => {
21
+ if (!params) {
22
+ return originUrl;
23
+ }
24
+ const withoutProtocol = originUrl.startsWith("//");
25
+ if (withoutProtocol) {
26
+ originUrl = location.protocol + originUrl;
27
+ }
28
+ try {
29
+ const url = new URL(originUrl);
30
+ Object.entries(params).forEach(([key, value]) => {
31
+ url == null ? void 0 : url.searchParams.set(key, value);
32
+ });
33
+ return `${withoutProtocol ? "" : url.protocol}//${url.host}${url.pathname}${url.search}`;
34
+ } catch (error) {
35
+ console.warn("URL 格式有误,请检查", error);
36
+ return originUrl;
37
+ }
38
+ };
39
+ var timeShift = "";
40
+ const live = window["VePlayer"].live;
41
+ const Plugin = window["VePlayer"].Plugin;
42
+ const Sniffer = window["VePlayer"].Sniffer;
43
+ const XGUtil = window["VePlayer"].util;
44
+ const { POSITIONS } = Plugin;
45
+ const { Events } = live;
46
+ const MAX_SHIFT = 7 * 24 * 3600;
47
+ const MIN_SHIFT = 6;
48
+ class TimeShift extends Plugin {
49
+ constructor() {
50
+ super(...arguments);
51
+ __publicField(this, "_isMobile", Sniffer.device === "mobile");
52
+ __publicField(this, "_playedBar", null);
53
+ __publicField(this, "_progressBtn", null);
54
+ __publicField(this, "_tooltip", null);
55
+ __publicField(this, "_backToLiveBtn", null);
56
+ __publicField(this, "_localInitTime", 0);
57
+ // 初始化时的客户端时间
58
+ __publicField(this, "_timeShiftInitRange", 0);
59
+ // 初始化时直播时移范围
60
+ __publicField(this, "_timeShiftOffset", 0);
61
+ // 当前时移时间
62
+ __publicField(this, "_isProgressMoving", false);
63
+ __publicField(this, "_liveUrl", "");
64
+ __publicField(this, "_stopPropagation", (e) => {
65
+ XGUtil.stopPropagation(e);
66
+ XGUtil.event(e);
67
+ });
68
+ }
69
+ static get pluginName() {
70
+ return "timeShift";
71
+ }
72
+ static get defaultConfig() {
73
+ return {
74
+ position: POSITIONS.CONTROLS_CENTER,
75
+ // 直播开始时间
76
+ liveStartTime: Date.now() / 1e3,
77
+ maxShiftOffset: 0,
78
+ // 当前时间
79
+ currentTime: Date.now() / 1e3
80
+ };
81
+ }
82
+ // 直播可时移范围
83
+ get _timeShiftLimit() {
84
+ const latestTimeShiftRange = this._timeShiftInitRange + Math.floor(Date.now() / 1e3 - this._localInitTime);
85
+ const { maxShiftOffset } = this.config ?? {};
86
+ if (latestTimeShiftRange > MAX_SHIFT) {
87
+ return MAX_SHIFT;
88
+ }
89
+ if (maxShiftOffset && latestTimeShiftRange > maxShiftOffset) {
90
+ return maxShiftOffset;
91
+ }
92
+ return latestTimeShiftRange;
93
+ }
94
+ registerLanguageTexts() {
95
+ return {
96
+ backToLive: {
97
+ jp: "ライブに戻る",
98
+ en: "Back to live",
99
+ zh: "返回直播",
100
+ "zh-hk": "返回直播"
101
+ }
102
+ };
103
+ }
104
+ updateLang() {
105
+ if (!this._backToLiveBtn)
106
+ return;
107
+ this._backToLiveBtn.innerHTML = this.langText.backToLive;
108
+ }
109
+ afterCreate() {
110
+ this._liveUrl = this.player.config.url;
111
+ this._playedBar = this.find(".xgplayer-progress-played");
112
+ this._progressBtn = this.find(".xgplayer-progress-btn");
113
+ this._tooltip = this.find(".xgplayer-shift-progress-point");
114
+ const { liveStartTime, currentTime } = this.config ?? {};
115
+ this._localInitTime = Math.floor(Date.now() / 1e3);
116
+ this._timeShiftInitRange = Math.floor(currentTime - liveStartTime);
117
+ this._createBackLiveBtDom();
118
+ this._initEvents();
119
+ this._bindDomEvents();
120
+ }
121
+ backToLive() {
122
+ if (!this._liveUrl) {
123
+ return;
124
+ }
125
+ this._switchUrl(this._liveUrl);
126
+ this._timeShiftOffset = 0;
127
+ this._toggleBackButton(false);
128
+ this.player.emit(Events.TIME_SHIFT_CHANGE, false);
129
+ }
130
+ destroy() {
131
+ var _a, _b, _c;
132
+ this.off(Events.TIME_UPDATE, this._handleTimeUpdate.bind(this));
133
+ if (this._isMobile) {
134
+ this.unbind("touchstart", this._handleMouseDown);
135
+ const controls = this.player.controls;
136
+ if (controls) {
137
+ (_a = controls.root) == null ? void 0 : _a.removerEventListener(
138
+ "touchmove",
139
+ XGUtil.stopPropagation
140
+ );
141
+ (_b = controls.center) == null ? void 0 : _b.removerEventListener(
142
+ "touchend",
143
+ XGUtil.stopPropagation
144
+ );
145
+ }
146
+ } else {
147
+ this.unbind("mousedown", this._handleMouseDown);
148
+ this.unbind("mouseenter", this._handleMouseEnter);
149
+ }
150
+ if (this._backToLiveBtn) {
151
+ (_c = this.player.root) == null ? void 0 : _c.removeChild(this._backToLiveBtn);
152
+ this._backToLiveBtn = null;
153
+ }
154
+ }
155
+ render() {
156
+ const controlsMode = this.player.controls ? this.player.controls.config.mode : "";
157
+ const className = controlsMode === "bottom" ? "xgplayer-progress-bottom" : "";
158
+ return `
159
+ <xg-progress class="xgplayer-progress ${className} xgplayer-shift">
160
+ <xg-back-live-bt class="xgplayer-back-live-bt"></xg-back-live-bt>
161
+ <xg-outer class="xgplayer-progress-outer">
162
+ <xg-inners class="progress-list">
163
+ <xg-inner class="xgplayer-progress-inner" style="flex: 1">
164
+ <xg-cache class="xgplayer-progress-cache" style="width: 100%;"></xg-cache>
165
+ <xg-played class="xgplayer-progress-played" style="width: 100%;"></xg-played>
166
+ </xg-inner>
167
+ </xg-inners>
168
+ <xg-progress-btn class="xgplayer-progress-btn"></xg-progress-btn>
169
+ <xg-point class="xgplayer-shift-progress-point">00:00</xg-point>
170
+ </xg-outer>
171
+ </xg-progress>
172
+ `;
173
+ }
174
+ _initEvents() {
175
+ this.on(Events.TIME_UPDATE, this._handleTimeUpdate.bind(this));
176
+ }
177
+ _bindDomEvents() {
178
+ var _a, _b;
179
+ this._handleMouseDown = this._handleMouseDown.bind(this);
180
+ this._handleMouseUp = this._handleMouseUp.bind(this);
181
+ this._handleMouseMove = this._handleMouseMove.bind(this);
182
+ this._handleMouseEnter = this._handleMouseEnter.bind(this);
183
+ this._handleMouseLeave = this._handleMouseLeave.bind(this);
184
+ this._tipsUpdate = this._tipsUpdate.bind(this);
185
+ if (this._isMobile) {
186
+ this.bind("touchstart", this._handleMouseDown);
187
+ const controls = this.player.controls;
188
+ if (controls) {
189
+ (_a = controls.root) == null ? void 0 : _a.addEventListener("touchmove", XGUtil.stopPropagation);
190
+ (_b = controls.center) == null ? void 0 : _b.addEventListener("touchend", XGUtil.stopPropagation);
191
+ }
192
+ } else {
193
+ this.bind("mousedown", this._handleMouseDown);
194
+ this.bind("mouseenter", this._handleMouseEnter);
195
+ }
196
+ }
197
+ _handleTimeUpdate() {
198
+ if (this._isProgressMoving) {
199
+ return;
200
+ }
201
+ this._progressUpdate();
202
+ }
203
+ _handleMouseDown(e) {
204
+ if (e.target === this._backToLiveBtn) {
205
+ return;
206
+ }
207
+ this._stopPropagation(e);
208
+ this._focus();
209
+ this._progressBtn && XGUtil.addClass(this._progressBtn, "active");
210
+ this._timeShiftOffset = this._getProgressOffset(e).progressOffset;
211
+ this._progressUpdate();
212
+ this._isProgressMoving = true;
213
+ if (this._isMobile) {
214
+ this.bind("touchmove", this._handleMouseMove);
215
+ this.bind("touchend", this._handleMouseUp);
216
+ } else {
217
+ document.addEventListener("mousemove", this._handleMouseMove, false);
218
+ document.addEventListener("mouseup", this._handleMouseUp, false);
219
+ }
220
+ }
221
+ _handleMouseMove(e) {
222
+ this._stopPropagation(e);
223
+ this._timeShiftOffset = this._getProgressOffset(e).progressOffset;
224
+ this._progressUpdate();
225
+ }
226
+ _handleMouseUp(e) {
227
+ this._stopPropagation(e);
228
+ this._isProgressMoving = false;
229
+ this._progressBtn && XGUtil.removeClass(this._progressBtn, "active");
230
+ this._changeTimeUrl();
231
+ if (this._isMobile) {
232
+ this.unbind("touchmove", this._handleMouseMove);
233
+ this.unbind("touchend", this._handleMouseUp);
234
+ } else {
235
+ document.removeEventListener("mousemove", this._handleMouseMove, false);
236
+ document.removeEventListener("mouseup", this._handleMouseUp, false);
237
+ }
238
+ }
239
+ _handleMouseEnter(e) {
240
+ this.bind("mouseleave", this._handleMouseLeave);
241
+ this.bind("mousemove", this._tipsUpdate);
242
+ this._tipsUpdate(e);
243
+ this._focus();
244
+ }
245
+ _handleMouseLeave() {
246
+ this.unbind("mouseleave", this._handleMouseLeave);
247
+ this.unbind("mousemove", this._tipsUpdate);
248
+ this._blur();
249
+ }
250
+ _focus() {
251
+ this.player.controls.pauseAutoHide();
252
+ XGUtil.addClass(this.root, "active");
253
+ }
254
+ _blur() {
255
+ this.player.controls.recoverAutoHide();
256
+ XGUtil.removeClass(this.root, "active");
257
+ }
258
+ _getProgressPercent(e) {
259
+ const { player } = this;
260
+ const { width, height, top, left } = this.root.getBoundingClientRect();
261
+ const _ePos = XGUtil.getEventPos(e, player.zoom);
262
+ let rWidth, rLeft, clientX;
263
+ if (player.rotateDeg === 90) {
264
+ rWidth = height;
265
+ rLeft = top;
266
+ clientX = _ePos.clientY;
267
+ } else {
268
+ rWidth = width;
269
+ rLeft = left;
270
+ clientX = _ePos.clientX;
271
+ }
272
+ let offset = clientX - rLeft;
273
+ offset = offset > rWidth ? rWidth : offset < 0 ? 0 : offset;
274
+ let percent = offset / rWidth;
275
+ percent = percent < 0 ? 0 : percent > 1 ? 1 : percent;
276
+ return percent;
277
+ }
278
+ _getProgressOffset(e) {
279
+ const percent = this._getProgressPercent(e);
280
+ return {
281
+ progressOffset: Math.floor(this._timeShiftLimit * (1 - percent)),
282
+ percent
283
+ };
284
+ }
285
+ _tipsUpdate(e) {
286
+ const { progressOffset, percent } = this._getProgressOffset(e);
287
+ if (!this._tooltip) {
288
+ return;
289
+ }
290
+ this._tooltip.style.left = `${percent * 100}%`;
291
+ this._tooltip.innerHTML = `-${formatTime(progressOffset)}`;
292
+ }
293
+ _progressUpdate() {
294
+ if (!this._progressBtn || !this._playedBar) {
295
+ return;
296
+ }
297
+ const progressPercent = Math.floor(this._timeShiftLimit - this._timeShiftOffset) / this._timeShiftLimit;
298
+ this._progressBtn.style.left = `${progressPercent * 100}%`;
299
+ this._playedBar.style.width = `${progressPercent * 100}%`;
300
+ }
301
+ _switchUrl(url) {
302
+ this.player.src = url;
303
+ this.player.config.url = url;
304
+ }
305
+ _changeTimeUrl() {
306
+ let shiftUrl = "";
307
+ this._toggleBackButton(true);
308
+ const _timeShiftOffset = this._timeShiftOffset < MIN_SHIFT ? MIN_SHIFT : this._timeShiftOffset;
309
+ shiftUrl = addUrlParam(this._liveUrl, {
310
+ timeshift: _timeShiftOffset
311
+ });
312
+ this._switchUrl(shiftUrl);
313
+ this.player.emit(Events.TIME_SHIFT_CHANGE, true);
314
+ }
315
+ _createBackLiveBtDom() {
316
+ var _a, _b;
317
+ if (this._backToLiveBtn) {
318
+ return;
319
+ }
320
+ this._backToLiveBtn = XGUtil.createDom(
321
+ "xg-back-live-bt",
322
+ this.langText.backToLive,
323
+ void 0,
324
+ "xgplayer-back-live-bt"
325
+ );
326
+ (_a = this._backToLiveBtn) == null ? void 0 : _a.addEventListener("click", () => {
327
+ this.backToLive();
328
+ });
329
+ (_b = this.player.root) == null ? void 0 : _b.appendChild(this._backToLiveBtn);
330
+ }
331
+ _toggleBackButton(isPlayTimeShift) {
332
+ if (!this._backToLiveBtn)
333
+ return;
334
+ this._backToLiveBtn.style.display = isPlayTimeShift ? "flex" : "none";
335
+ }
336
+ }
337
+ export {
338
+ TimeShift as default
339
+ };
@@ -0,0 +1 @@
1
+ .xgplayer-shift .xgplayer-shift-progress-point{position:absolute;top:-30px;display:none;width:60px;padding:6px 0;color:#fff;font-size:12px;line-height:18px;text-align:center;background:rgba(0,0,0,.6);border-radius:2px;transform:translate(-50%)}.xgplayer-shift.active .xgplayer-shift-progress-point{display:block}.xgplayer-shift.xgplayer-progress .xgplayer-progress-outer{transition:unset}.xgplayer-shift.xgplayer-progress .xgplayer-progress-btn{width:16px;height:16px;background:#346aff41;box-shadow:0 0 1px rgba(0,0,0,.094)}.xgplayer-shift.xgplayer-progress .xgplayer-progress-played{background:#3469ff}.xgplayer-back-live-bt{position:absolute;bottom:60px;left:20px;display:none;align-items:center;justify-content:center;width:96px;height:32px;color:#fff;font-size:13px;background:rgba(0,0,0,.4);border:1px solid rgba(255,255,255,.8);border-radius:16px;cursor:pointer}.xgplayer-back-live-bt:hover{background:rgba(0,0,0,.6)}.xgplayer-inactive .xgplayer-back-live-bt{display:none}.xgplayer-mobile .xgplayer-shift{margin:0 8px}.xgplayer-mobile .xgplayer-shift .xgplayer-shift-progress-point{display:none}.xgplayer-mobile .xgplayer-back-live-bt{bottom:40px;width:86px;height:25px;font-size:12px}