stormcloud-video-player 0.3.53 → 0.3.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +1315 -1140
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +391 -221
- package/lib/index.d.ts +391 -221
- package/lib/index.js +1264 -1101
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +547 -148
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +13 -1
- package/lib/players/FilePlayer.cjs +99 -116
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +599 -200
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +678 -279
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +17 -9
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +43 -48
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-DYelrVG6.d.cts → types-C23mJ_hh.d.cts} +15 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +1124 -961
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs +11 -11
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs +13 -13
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs +283 -14
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +12 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StormcloudVideoPlayerConfig } from '../types-
|
|
1
|
+
import { S as StormcloudVideoPlayerConfig } from '../types-C23mJ_hh.cjs';
|
|
2
2
|
|
|
3
3
|
declare class StormcloudVideoPlayer {
|
|
4
4
|
private readonly video;
|
|
@@ -52,10 +52,18 @@ declare class StormcloudVideoPlayer {
|
|
|
52
52
|
private readonly backoffBaseMs;
|
|
53
53
|
private readonly maxBackoffMs;
|
|
54
54
|
private placeholderContainer;
|
|
55
|
+
private globalConsecutiveNoFills;
|
|
56
|
+
private readonly globalNoFillThreshold;
|
|
57
|
+
private globalNoFillCooldownUntil;
|
|
58
|
+
private readonly globalNoFillBackoffBaseMs;
|
|
59
|
+
private readonly globalNoFillBackoffMaxMs;
|
|
60
|
+
private globalLastGamRequestTime;
|
|
61
|
+
private readonly globalMinGamIntervalMs;
|
|
55
62
|
private preloadPool;
|
|
56
63
|
private readonly maxPreloadPoolSize;
|
|
57
64
|
private preloadPoolActive;
|
|
58
65
|
private preloadPoolLoopRunning;
|
|
66
|
+
private adDetectSentForCurrentBreak;
|
|
59
67
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
60
68
|
private createAdPlayer;
|
|
61
69
|
load(): Promise<void>;
|
|
@@ -114,6 +122,10 @@ declare class StormcloudVideoPlayer {
|
|
|
114
122
|
private isTemporaryAdError;
|
|
115
123
|
private isUrlInCooldown;
|
|
116
124
|
private cleanupTemporaryFailures;
|
|
125
|
+
private isGamInCooldown;
|
|
126
|
+
private recordGamNoFill;
|
|
127
|
+
private resetGamNoFillCounter;
|
|
128
|
+
private enforceGlobalRateLimit;
|
|
117
129
|
private playSingleAd;
|
|
118
130
|
private handleAdPodComplete;
|
|
119
131
|
private handleAdFailure;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function _array_like_to_array(arr, len) {
|
|
3
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
-
return arr2;
|
|
6
|
-
}
|
|
7
|
-
function _array_without_holes(arr) {
|
|
8
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
|
-
}
|
|
10
2
|
function _assert_this_initialized(self) {
|
|
11
3
|
if (self === void 0) {
|
|
12
4
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -84,12 +76,6 @@ function _inherits(subClass, superClass) {
|
|
|
84
76
|
});
|
|
85
77
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
86
78
|
}
|
|
87
|
-
function _iterable_to_array(iter) {
|
|
88
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
89
|
-
}
|
|
90
|
-
function _non_iterable_spread() {
|
|
91
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
|
-
}
|
|
93
79
|
function _possible_constructor_return(self, call) {
|
|
94
80
|
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
95
81
|
return call;
|
|
@@ -103,21 +89,10 @@ function _set_prototype_of(o, p) {
|
|
|
103
89
|
};
|
|
104
90
|
return _set_prototype_of(o, p);
|
|
105
91
|
}
|
|
106
|
-
function _to_consumable_array(arr) {
|
|
107
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
108
|
-
}
|
|
109
92
|
function _type_of(obj) {
|
|
110
93
|
"@swc/helpers - typeof";
|
|
111
94
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
112
95
|
}
|
|
113
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
114
|
-
if (!o) return;
|
|
115
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
116
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
117
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
118
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
119
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
120
|
-
}
|
|
121
96
|
function _is_native_reflect_construct() {
|
|
122
97
|
try {
|
|
123
98
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
@@ -135,9 +110,17 @@ function _ts_generator(thisArg, body) {
|
|
|
135
110
|
},
|
|
136
111
|
trys: [],
|
|
137
112
|
ops: []
|
|
138
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
139
|
-
return
|
|
140
|
-
|
|
113
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
114
|
+
return d(g, "next", {
|
|
115
|
+
value: verb(0)
|
|
116
|
+
}), d(g, "throw", {
|
|
117
|
+
value: verb(1)
|
|
118
|
+
}), d(g, "return", {
|
|
119
|
+
value: verb(2)
|
|
120
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
121
|
+
value: function() {
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
141
124
|
}), g;
|
|
142
125
|
function verb(n) {
|
|
143
126
|
return function(v) {
|
|
@@ -221,20 +204,20 @@ var __defProp = Object.defineProperty;
|
|
|
221
204
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
222
205
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
223
206
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
224
|
-
var __export = function(target, all) {
|
|
207
|
+
var __export = function __export(target, all) {
|
|
225
208
|
for(var name in all)__defProp(target, name, {
|
|
226
209
|
get: all[name],
|
|
227
210
|
enumerable: true
|
|
228
211
|
});
|
|
229
212
|
};
|
|
230
|
-
var __copyProps = function(to, from, except, desc) {
|
|
213
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
231
214
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
232
215
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
233
216
|
try {
|
|
234
217
|
var _loop = function() {
|
|
235
218
|
var key = _step.value;
|
|
236
219
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
237
|
-
get: function() {
|
|
220
|
+
get: function get() {
|
|
238
221
|
return from[key];
|
|
239
222
|
},
|
|
240
223
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -258,7 +241,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
258
241
|
}
|
|
259
242
|
return to;
|
|
260
243
|
};
|
|
261
|
-
var __toCommonJS = function(mod) {
|
|
244
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
262
245
|
return __copyProps(__defProp({}, "__esModule", {
|
|
263
246
|
value: true
|
|
264
247
|
}), mod);
|
|
@@ -266,7 +249,7 @@ var __toCommonJS = function(mod) {
|
|
|
266
249
|
// src/players/FilePlayer.tsx
|
|
267
250
|
var FilePlayer_exports = {};
|
|
268
251
|
__export(FilePlayer_exports, {
|
|
269
|
-
default: function() {
|
|
252
|
+
default: function _default() {
|
|
270
253
|
return FilePlayer;
|
|
271
254
|
}
|
|
272
255
|
});
|
|
@@ -279,23 +262,23 @@ var DASH_EXTENSIONS = /\.(mpd)($|\?)/i;
|
|
|
279
262
|
var VIDEO_EXTENSIONS = /\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\?)/i;
|
|
280
263
|
var AUDIO_EXTENSIONS = /\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\?)/i;
|
|
281
264
|
var canPlay = {
|
|
282
|
-
hls: function(url) {
|
|
265
|
+
hls: function hls(url) {
|
|
283
266
|
if (!url || typeof url !== "string") return false;
|
|
284
267
|
return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);
|
|
285
268
|
},
|
|
286
|
-
dash: function(url) {
|
|
269
|
+
dash: function dash(url) {
|
|
287
270
|
if (!url || typeof url !== "string") return false;
|
|
288
271
|
return DASH_EXTENSIONS.test(url);
|
|
289
272
|
},
|
|
290
|
-
video: function(url) {
|
|
273
|
+
video: function video(url) {
|
|
291
274
|
if (!url || typeof url !== "string") return false;
|
|
292
275
|
return VIDEO_EXTENSIONS.test(url);
|
|
293
276
|
},
|
|
294
|
-
audio: function(url) {
|
|
277
|
+
audio: function audio(url) {
|
|
295
278
|
if (!url || typeof url !== "string") return false;
|
|
296
279
|
return AUDIO_EXTENSIONS.test(url);
|
|
297
280
|
},
|
|
298
|
-
file: function(url) {
|
|
281
|
+
file: function file(url) {
|
|
299
282
|
if (!url || typeof url !== "string") return false;
|
|
300
283
|
return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);
|
|
301
284
|
}
|
|
@@ -306,49 +289,49 @@ var FilePlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
|
306
289
|
function FilePlayer() {
|
|
307
290
|
_class_call_check(this, FilePlayer);
|
|
308
291
|
var _this;
|
|
309
|
-
var _this1
|
|
310
|
-
_this = _call_super(this, FilePlayer,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
292
|
+
var _this1;
|
|
293
|
+
_this = _call_super(this, FilePlayer, arguments), _this1 = _this;
|
|
294
|
+
_this.mounted = false;
|
|
295
|
+
_this.ready = false;
|
|
296
|
+
_this.load = function() {
|
|
314
297
|
var _this_props_onMount, _this_props;
|
|
315
|
-
if (!
|
|
316
|
-
var video =
|
|
317
|
-
var handleLoadedMetadata = function() {
|
|
318
|
-
if (
|
|
298
|
+
if (!_this.props.videoElement || !_this.props.src) return;
|
|
299
|
+
var video = _this.props.videoElement;
|
|
300
|
+
var handleLoadedMetadata = function handleLoadedMetadata() {
|
|
301
|
+
if (_this.mounted && !_this.ready) {
|
|
319
302
|
var _this_props_onReady, _this_props;
|
|
320
|
-
|
|
321
|
-
(_this_props_onReady = (_this_props =
|
|
303
|
+
_this.ready = true;
|
|
304
|
+
(_this_props_onReady = (_this_props = _this.props).onReady) === null || _this_props_onReady === void 0 ? void 0 : _this_props_onReady.call(_this_props);
|
|
322
305
|
}
|
|
323
306
|
};
|
|
324
|
-
var handlePlay = function() {
|
|
325
|
-
if (
|
|
307
|
+
var handlePlay = function handlePlay() {
|
|
308
|
+
if (_this.mounted) {
|
|
326
309
|
var _this_props_onPlay, _this_props;
|
|
327
|
-
(_this_props_onPlay = (_this_props =
|
|
310
|
+
(_this_props_onPlay = (_this_props = _this.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
|
|
328
311
|
}
|
|
329
312
|
};
|
|
330
|
-
var handlePause = function() {
|
|
331
|
-
if (
|
|
313
|
+
var handlePause = function handlePause() {
|
|
314
|
+
if (_this.mounted) {
|
|
332
315
|
var _this_props_onPause, _this_props;
|
|
333
|
-
(_this_props_onPause = (_this_props =
|
|
316
|
+
(_this_props_onPause = (_this_props = _this.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
|
|
334
317
|
}
|
|
335
318
|
};
|
|
336
|
-
var handleEnded = function() {
|
|
337
|
-
if (
|
|
319
|
+
var handleEnded = function handleEnded() {
|
|
320
|
+
if (_this.mounted) {
|
|
338
321
|
var _this_props_onEnded, _this_props;
|
|
339
|
-
(_this_props_onEnded = (_this_props =
|
|
322
|
+
(_this_props_onEnded = (_this_props = _this.props).onEnded) === null || _this_props_onEnded === void 0 ? void 0 : _this_props_onEnded.call(_this_props);
|
|
340
323
|
}
|
|
341
324
|
};
|
|
342
|
-
var handleError = function(error) {
|
|
343
|
-
if (
|
|
325
|
+
var handleError = function handleError(error) {
|
|
326
|
+
if (_this.mounted) {
|
|
344
327
|
var _this_props_onError, _this_props;
|
|
345
|
-
(_this_props_onError = (_this_props =
|
|
328
|
+
(_this_props_onError = (_this_props = _this.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
|
|
346
329
|
}
|
|
347
330
|
};
|
|
348
|
-
var handleLoadedData = function() {
|
|
349
|
-
if (
|
|
331
|
+
var handleLoadedData = function handleLoadedData() {
|
|
332
|
+
if (_this.mounted) {
|
|
350
333
|
var _this_props_onLoaded, _this_props;
|
|
351
|
-
(_this_props_onLoaded = (_this_props =
|
|
334
|
+
(_this_props_onLoaded = (_this_props = _this.props).onLoaded) === null || _this_props_onLoaded === void 0 ? void 0 : _this_props_onLoaded.call(_this_props);
|
|
352
335
|
}
|
|
353
336
|
};
|
|
354
337
|
video.addEventListener("loadedmetadata", handleLoadedMetadata);
|
|
@@ -357,15 +340,15 @@ var FilePlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
|
357
340
|
video.addEventListener("ended", handleEnded);
|
|
358
341
|
video.addEventListener("error", handleError);
|
|
359
342
|
video.addEventListener("loadeddata", handleLoadedData);
|
|
360
|
-
video.src =
|
|
361
|
-
if (
|
|
362
|
-
if (
|
|
363
|
-
if (
|
|
364
|
-
if (
|
|
365
|
-
if (
|
|
366
|
-
if (
|
|
367
|
-
if (
|
|
368
|
-
(_this_props_onMount = (_this_props =
|
|
343
|
+
video.src = _this.props.src;
|
|
344
|
+
if (_this.props.autoplay !== void 0) video.autoplay = _this.props.autoplay;
|
|
345
|
+
if (_this.props.muted !== void 0) video.muted = _this.props.muted;
|
|
346
|
+
if (_this.props.loop !== void 0) video.loop = _this.props.loop;
|
|
347
|
+
if (_this.props.controls !== void 0) video.controls = _this.props.controls;
|
|
348
|
+
if (_this.props.playsInline !== void 0) video.playsInline = _this.props.playsInline;
|
|
349
|
+
if (_this.props.preload !== void 0) video.preload = _this.props.preload;
|
|
350
|
+
if (_this.props.poster !== void 0) video.poster = _this.props.poster;
|
|
351
|
+
(_this_props_onMount = (_this_props = _this.props).onMount) === null || _this_props_onMount === void 0 ? void 0 : _this_props_onMount.call(_this_props, _this);
|
|
369
352
|
return function() {
|
|
370
353
|
video.removeEventListener("loadedmetadata", handleLoadedMetadata);
|
|
371
354
|
video.removeEventListener("play", handlePlay);
|
|
@@ -375,90 +358,90 @@ var FilePlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
|
375
358
|
video.removeEventListener("loadeddata", handleLoadedData);
|
|
376
359
|
};
|
|
377
360
|
};
|
|
378
|
-
|
|
379
|
-
if (
|
|
380
|
-
var video =
|
|
361
|
+
_this.play = function() {
|
|
362
|
+
if (_this.props.videoElement) {
|
|
363
|
+
var video = _this.props.videoElement;
|
|
381
364
|
var hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
|
|
382
365
|
if (hasValidSource) {
|
|
383
366
|
var _video_play;
|
|
384
367
|
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function(error) {
|
|
385
368
|
var _this_props_onError, _this_props;
|
|
386
369
|
console.error("[FilePlayer] Failed to play:", error);
|
|
387
|
-
(_this_props_onError = (_this_props =
|
|
370
|
+
(_this_props_onError = (_this_props = _this.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
|
|
388
371
|
});
|
|
389
372
|
} else {
|
|
390
373
|
console.warn("[FilePlayer] Cannot play: video has no valid source");
|
|
391
374
|
}
|
|
392
375
|
}
|
|
393
376
|
};
|
|
394
|
-
|
|
395
|
-
if (
|
|
396
|
-
|
|
377
|
+
_this.pause = function() {
|
|
378
|
+
if (_this.props.videoElement) {
|
|
379
|
+
_this.props.videoElement.pause();
|
|
397
380
|
}
|
|
398
381
|
};
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (
|
|
402
|
-
|
|
382
|
+
_this.stop = function() {
|
|
383
|
+
_this.pause();
|
|
384
|
+
if (_this.props.videoElement) {
|
|
385
|
+
_this.props.videoElement.currentTime = 0;
|
|
403
386
|
}
|
|
404
387
|
};
|
|
405
|
-
|
|
406
|
-
if (
|
|
407
|
-
|
|
388
|
+
_this.seekTo = function(seconds, keepPlaying) {
|
|
389
|
+
if (_this.props.videoElement) {
|
|
390
|
+
_this.props.videoElement.currentTime = seconds;
|
|
408
391
|
if (!keepPlaying) {
|
|
409
|
-
|
|
392
|
+
_this.pause();
|
|
410
393
|
}
|
|
411
394
|
}
|
|
412
395
|
};
|
|
413
|
-
|
|
414
|
-
if (
|
|
415
|
-
|
|
396
|
+
_this.setVolume = function(volume) {
|
|
397
|
+
if (_this.props.videoElement) {
|
|
398
|
+
_this.props.videoElement.volume = Math.max(0, Math.min(1, volume));
|
|
416
399
|
}
|
|
417
400
|
};
|
|
418
|
-
|
|
419
|
-
if (
|
|
420
|
-
|
|
401
|
+
_this.mute = function() {
|
|
402
|
+
if (_this.props.videoElement) {
|
|
403
|
+
_this.props.videoElement.muted = true;
|
|
421
404
|
}
|
|
422
405
|
};
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
|
|
406
|
+
_this.unmute = function() {
|
|
407
|
+
if (_this.props.videoElement) {
|
|
408
|
+
_this.props.videoElement.muted = false;
|
|
426
409
|
}
|
|
427
410
|
};
|
|
428
|
-
|
|
429
|
-
if (
|
|
430
|
-
|
|
411
|
+
_this.setPlaybackRate = function(rate) {
|
|
412
|
+
if (_this.props.videoElement && rate > 0) {
|
|
413
|
+
_this.props.videoElement.playbackRate = rate;
|
|
431
414
|
}
|
|
432
415
|
};
|
|
433
|
-
|
|
434
|
-
if (
|
|
435
|
-
|
|
416
|
+
_this.setLoop = function(loop) {
|
|
417
|
+
if (_this.props.videoElement) {
|
|
418
|
+
_this.props.videoElement.loop = loop;
|
|
436
419
|
}
|
|
437
420
|
};
|
|
438
|
-
|
|
439
|
-
if (
|
|
440
|
-
return
|
|
421
|
+
_this.getDuration = function() {
|
|
422
|
+
if (_this.props.videoElement && isFinite(_this.props.videoElement.duration)) {
|
|
423
|
+
return _this.props.videoElement.duration;
|
|
441
424
|
}
|
|
442
425
|
return null;
|
|
443
426
|
};
|
|
444
|
-
|
|
445
|
-
if (
|
|
446
|
-
return
|
|
427
|
+
_this.getCurrentTime = function() {
|
|
428
|
+
if (_this.props.videoElement && isFinite(_this.props.videoElement.currentTime)) {
|
|
429
|
+
return _this.props.videoElement.currentTime;
|
|
447
430
|
}
|
|
448
431
|
return null;
|
|
449
432
|
};
|
|
450
|
-
|
|
451
|
-
if (
|
|
452
|
-
return
|
|
433
|
+
_this.getSecondsLoaded = function() {
|
|
434
|
+
if (_this.props.videoElement && _this.props.videoElement.buffered.length > 0) {
|
|
435
|
+
return _this.props.videoElement.buffered.end(_this.props.videoElement.buffered.length - 1);
|
|
453
436
|
}
|
|
454
437
|
return null;
|
|
455
438
|
};
|
|
456
|
-
|
|
439
|
+
_this.getInternalPlayer = function() {
|
|
457
440
|
var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "player";
|
|
458
|
-
if (key === "video") return
|
|
441
|
+
if (key === "video") return _this.props.videoElement;
|
|
459
442
|
return null;
|
|
460
443
|
};
|
|
461
|
-
|
|
444
|
+
_this.enablePIP = function() {
|
|
462
445
|
return _async_to_generator(function() {
|
|
463
446
|
var error;
|
|
464
447
|
return _ts_generator(this, function(_state) {
|
|
@@ -501,7 +484,7 @@ var FilePlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
|
501
484
|
});
|
|
502
485
|
})();
|
|
503
486
|
};
|
|
504
|
-
|
|
487
|
+
_this.disablePIP = function() {
|
|
505
488
|
return _async_to_generator(function() {
|
|
506
489
|
var error;
|
|
507
490
|
return _ts_generator(this, function(_state) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/ubuntu24/Dev/stormcloud-vp/lib/players/FilePlayer.cjs"],"names":["
|
|
1
|
+
{"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/players/FilePlayer.cjs"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","name","all","target","enumerable","__copyProps","to","from","except","desc","key","call"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YACIA,OAAAA,GAAYC,OAAOC,cAAc;QACjCC,mBAAmBF,OAAOG,wBAAwB;QAClDC,MAAAA,SAAAA,GAAAA,GAAoBJ,OAAOK,mBAAmB;;;;;;iCAC9CC,CAAAA,OAAAA,IAAeN,CAAAA,CAAAA,KAAOO,OAAAA,EAAS,CAACC,CAAAA,aAAc,gBAAA,OAAA,KAAA,CAAA,YAAA,GAA9CF;;;;;;;;;;;;4BAEG;;gCAAIG,IAAQC,GAAAA,GACfX,EAAAA,CAAAA,OAAUY,KAAAA,CAAAA,EAAQF,MAAM,eAAA;;;4BADrB,EAAIA;;;;;;4BAC4BA,KAAK;4BAAEG,QAAAA,EAAY,EAAA,CAAA,8BAAA;;;;;;;;;;;YAEtDC,cAAc,qBAACC,IAAIC,MAAMC,QAAQC;;QACnC,IAAIF,EAAAA,OAAQ,CAAA,EAAA,GAAA,EAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;;oBAC7D;;;;0CAAA,uBAAA,IAAA,2BAAA;;;;;;;;;;;;;;;;;;;;;;;4BAAA,GAAIG,MAAJ;kCACH,EAAA,EAAI,CAACZ,CAAAA,CAAAA,WAAaa,IAAI,CAACL,IAAII,QAAQA,OAAAA,CAAQF,QACzCjB,UAAUe,IAAII,KAAK;;;;;;;;;;;;;;;;;;0CAA6F;;wBAFpH,CAAA,OAAK,YAAWd,kBAAkBW,0BAA7B,SAAA,6BAAA,QAAA,yBAAA;;;;;sCAAA;wBAAA,IAAA,GAAA;;;;;;iCAAA,KAAA,IAAA,CAAA,KAAA,CAAA,GAAA,EAAA,QAAA;kCAAA;;;;;mCAAA;;sCAAA;;;;;;;IAGP,OAAA,OAAA,GAAA,QAAA,IAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/players/FilePlayer.tsx\nvar FilePlayer_exports = {};\n__export(FilePlayer_exports, {\n default: () => FilePlayer\n});\nmodule.exports = __toCommonJS(FilePlayer_exports);\nvar import_react = require(\"react\");\n\n// src/patterns.ts\nvar HLS_EXTENSIONS = /\\.(m3u8)($|\\?)/i;\nvar HLS_PATHS = /\\/hls\\//i;\nvar DASH_EXTENSIONS = /\\.(mpd)($|\\?)/i;\nvar VIDEO_EXTENSIONS = /\\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\\?)/i;\nvar AUDIO_EXTENSIONS = /\\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\\?)/i;\nvar canPlay = {\n hls: (url) => {\n if (!url || typeof url !== \"string\") return false;\n return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);\n },\n dash: (url) => {\n if (!url || typeof url !== \"string\") return false;\n return DASH_EXTENSIONS.test(url);\n },\n video: (url) => {\n if (!url || typeof url !== \"string\") return false;\n return VIDEO_EXTENSIONS.test(url);\n },\n audio: (url) => {\n if (!url || typeof url !== \"string\") return false;\n return AUDIO_EXTENSIONS.test(url);\n },\n file: (url) => {\n if (!url || typeof url !== \"string\") return false;\n return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);\n }\n};\n\n// src/players/FilePlayer.tsx\nvar FilePlayer = class extends import_react.Component {\n constructor() {\n super(...arguments);\n this.mounted = false;\n this.ready = false;\n this.load = () => {\n if (!this.props.videoElement || !this.props.src) return;\n const video = this.props.videoElement;\n const handleLoadedMetadata = () => {\n if (this.mounted && !this.ready) {\n this.ready = true;\n this.props.onReady?.();\n }\n };\n const handlePlay = () => {\n if (this.mounted) {\n this.props.onPlay?.();\n }\n };\n const handlePause = () => {\n if (this.mounted) {\n this.props.onPause?.();\n }\n };\n const handleEnded = () => {\n if (this.mounted) {\n this.props.onEnded?.();\n }\n };\n const handleError = (error) => {\n if (this.mounted) {\n this.props.onError?.(error);\n }\n };\n const handleLoadedData = () => {\n if (this.mounted) {\n this.props.onLoaded?.();\n }\n };\n video.addEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n video.addEventListener(\"ended\", handleEnded);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", handleLoadedData);\n video.src = this.props.src;\n if (this.props.autoplay !== void 0) video.autoplay = this.props.autoplay;\n if (this.props.muted !== void 0) video.muted = this.props.muted;\n if (this.props.loop !== void 0) video.loop = this.props.loop;\n if (this.props.controls !== void 0) video.controls = this.props.controls;\n if (this.props.playsInline !== void 0)\n video.playsInline = this.props.playsInline;\n if (this.props.preload !== void 0)\n video.preload = this.props.preload;\n if (this.props.poster !== void 0) video.poster = this.props.poster;\n this.props.onMount?.(this);\n return () => {\n video.removeEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n video.removeEventListener(\"ended\", handleEnded);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", handleLoadedData);\n };\n };\n this.play = () => {\n if (this.props.videoElement) {\n const video = this.props.videoElement;\n const hasValidSource = video.src || video.currentSrc && video.currentSrc !== \"\" || video.readyState >= 1;\n if (hasValidSource) {\n video.play()?.catch((error) => {\n console.error(\"[FilePlayer] Failed to play:\", error);\n this.props.onError?.(error);\n });\n } else {\n console.warn(\"[FilePlayer] Cannot play: video has no valid source\");\n }\n }\n };\n this.pause = () => {\n if (this.props.videoElement) {\n this.props.videoElement.pause();\n }\n };\n this.stop = () => {\n this.pause();\n if (this.props.videoElement) {\n this.props.videoElement.currentTime = 0;\n }\n };\n this.seekTo = (seconds, keepPlaying) => {\n if (this.props.videoElement) {\n this.props.videoElement.currentTime = seconds;\n if (!keepPlaying) {\n this.pause();\n }\n }\n };\n this.setVolume = (volume) => {\n if (this.props.videoElement) {\n this.props.videoElement.volume = Math.max(0, Math.min(1, volume));\n }\n };\n this.mute = () => {\n if (this.props.videoElement) {\n this.props.videoElement.muted = true;\n }\n };\n this.unmute = () => {\n if (this.props.videoElement) {\n this.props.videoElement.muted = false;\n }\n };\n this.setPlaybackRate = (rate) => {\n if (this.props.videoElement && rate > 0) {\n this.props.videoElement.playbackRate = rate;\n }\n };\n this.setLoop = (loop) => {\n if (this.props.videoElement) {\n this.props.videoElement.loop = loop;\n }\n };\n this.getDuration = () => {\n if (this.props.videoElement && isFinite(this.props.videoElement.duration)) {\n return this.props.videoElement.duration;\n }\n return null;\n };\n this.getCurrentTime = () => {\n if (this.props.videoElement && isFinite(this.props.videoElement.currentTime)) {\n return this.props.videoElement.currentTime;\n }\n return null;\n };\n this.getSecondsLoaded = () => {\n if (this.props.videoElement && this.props.videoElement.buffered.length > 0) {\n return this.props.videoElement.buffered.end(\n this.props.videoElement.buffered.length - 1\n );\n }\n return null;\n };\n this.getInternalPlayer = (key = \"player\") => {\n if (key === \"video\") return this.props.videoElement;\n return null;\n };\n this.enablePIP = async () => {\n if (this.props.videoElement && \"requestPictureInPicture\" in this.props.videoElement) {\n try {\n await this.props.videoElement.requestPictureInPicture();\n } catch (error) {\n console.warn(\"Picture-in-Picture failed:\", error);\n }\n }\n };\n this.disablePIP = async () => {\n if (document.pictureInPictureElement) {\n try {\n await document.exitPictureInPicture();\n } catch (error) {\n console.warn(\"Exit Picture-in-Picture failed:\", error);\n }\n }\n };\n }\n componentDidMount() {\n this.mounted = true;\n this.load();\n }\n componentWillUnmount() {\n this.mounted = false;\n }\n componentDidUpdate(prevProps) {\n if (prevProps.src !== this.props.src) {\n this.load();\n }\n }\n render() {\n return null;\n }\n};\nFilePlayer.displayName = \"FilePlayer\";\nFilePlayer.canPlay = canPlay.file;\n"]}
|