stormcloud-video-player 0.3.14 → 0.3.16
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 +9 -9
- package/lib/index.cjs +8282 -6531
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8112 -6495
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +5575 -3981
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/FilePlayer.cjs +556 -225
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +5845 -4163
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +6142 -4371
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +954 -699
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +1034 -809
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-t9jEJXZy.d.cts → types-CryTJVCC.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +6992 -5561
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs +241 -194
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs +379 -214
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs +559 -257
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +2 -1
|
@@ -1,30 +1,277 @@
|
|
|
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
|
+
function _assert_this_initialized(self) {
|
|
11
|
+
if (self === void 0) {
|
|
12
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
}
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(undefined);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function _call_super(_this, derived, args) {
|
|
46
|
+
derived = _get_prototype_of(derived);
|
|
47
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
48
|
+
}
|
|
49
|
+
function _class_call_check(instance, Constructor) {
|
|
50
|
+
if (!(instance instanceof Constructor)) {
|
|
51
|
+
throw new TypeError("Cannot call a class as a function");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function _defineProperties(target, props) {
|
|
55
|
+
for(var i = 0; i < props.length; i++){
|
|
56
|
+
var descriptor = props[i];
|
|
57
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
58
|
+
descriptor.configurable = true;
|
|
59
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
60
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
64
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
65
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
66
|
+
return Constructor;
|
|
67
|
+
}
|
|
68
|
+
function _get_prototype_of(o) {
|
|
69
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
70
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
71
|
+
};
|
|
72
|
+
return _get_prototype_of(o);
|
|
73
|
+
}
|
|
74
|
+
function _inherits(subClass, superClass) {
|
|
75
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
76
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
77
|
+
}
|
|
78
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
79
|
+
constructor: {
|
|
80
|
+
value: subClass,
|
|
81
|
+
writable: true,
|
|
82
|
+
configurable: true
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
86
|
+
}
|
|
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
|
+
function _possible_constructor_return(self, call) {
|
|
94
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
95
|
+
return call;
|
|
96
|
+
}
|
|
97
|
+
return _assert_this_initialized(self);
|
|
98
|
+
}
|
|
99
|
+
function _set_prototype_of(o, p) {
|
|
100
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
101
|
+
o.__proto__ = p;
|
|
102
|
+
return o;
|
|
103
|
+
};
|
|
104
|
+
return _set_prototype_of(o, p);
|
|
105
|
+
}
|
|
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
|
+
function _type_of(obj) {
|
|
110
|
+
"@swc/helpers - typeof";
|
|
111
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
112
|
+
}
|
|
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
|
+
function _is_native_reflect_construct() {
|
|
122
|
+
try {
|
|
123
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
124
|
+
} catch (_) {}
|
|
125
|
+
return (_is_native_reflect_construct = function() {
|
|
126
|
+
return !!result;
|
|
127
|
+
})();
|
|
128
|
+
}
|
|
129
|
+
function _ts_generator(thisArg, body) {
|
|
130
|
+
var f, y, t, _ = {
|
|
131
|
+
label: 0,
|
|
132
|
+
sent: function() {
|
|
133
|
+
if (t[0] & 1) throw t[1];
|
|
134
|
+
return t[1];
|
|
135
|
+
},
|
|
136
|
+
trys: [],
|
|
137
|
+
ops: []
|
|
138
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
139
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
140
|
+
return this;
|
|
141
|
+
}), g;
|
|
142
|
+
function verb(n) {
|
|
143
|
+
return function(v) {
|
|
144
|
+
return step([
|
|
145
|
+
n,
|
|
146
|
+
v
|
|
147
|
+
]);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function step(op) {
|
|
151
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
152
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
153
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
154
|
+
if (y = 0, t) op = [
|
|
155
|
+
op[0] & 2,
|
|
156
|
+
t.value
|
|
157
|
+
];
|
|
158
|
+
switch(op[0]){
|
|
159
|
+
case 0:
|
|
160
|
+
case 1:
|
|
161
|
+
t = op;
|
|
162
|
+
break;
|
|
163
|
+
case 4:
|
|
164
|
+
_.label++;
|
|
165
|
+
return {
|
|
166
|
+
value: op[1],
|
|
167
|
+
done: false
|
|
168
|
+
};
|
|
169
|
+
case 5:
|
|
170
|
+
_.label++;
|
|
171
|
+
y = op[1];
|
|
172
|
+
op = [
|
|
173
|
+
0
|
|
174
|
+
];
|
|
175
|
+
continue;
|
|
176
|
+
case 7:
|
|
177
|
+
op = _.ops.pop();
|
|
178
|
+
_.trys.pop();
|
|
179
|
+
continue;
|
|
180
|
+
default:
|
|
181
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
182
|
+
_ = 0;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
186
|
+
_.label = op[1];
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
190
|
+
_.label = t[1];
|
|
191
|
+
t = op;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
if (t && _.label < t[2]) {
|
|
195
|
+
_.label = t[2];
|
|
196
|
+
_.ops.push(op);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (t[2]) _.ops.pop();
|
|
200
|
+
_.trys.pop();
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
op = body.call(thisArg, _);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
op = [
|
|
206
|
+
6,
|
|
207
|
+
e
|
|
208
|
+
];
|
|
209
|
+
y = 0;
|
|
210
|
+
} finally{
|
|
211
|
+
f = t = 0;
|
|
212
|
+
}
|
|
213
|
+
if (op[0] & 5) throw op[1];
|
|
214
|
+
return {
|
|
215
|
+
value: op[0] ? op[1] : void 0,
|
|
216
|
+
done: true
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
2
220
|
var __defProp = Object.defineProperty;
|
|
3
221
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
222
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
223
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all)
|
|
7
|
-
|
|
8
|
-
|
|
224
|
+
var __export = function(target, all) {
|
|
225
|
+
for(var name in all)__defProp(target, name, {
|
|
226
|
+
get: all[name],
|
|
227
|
+
enumerable: true
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
var __copyProps = function(to, from, except, desc) {
|
|
231
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
232
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
233
|
+
try {
|
|
234
|
+
var _loop = function() {
|
|
235
|
+
var key = _step.value;
|
|
236
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
237
|
+
get: function() {
|
|
238
|
+
return from[key];
|
|
239
|
+
},
|
|
240
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_didIteratorError = true;
|
|
246
|
+
_iteratorError = err;
|
|
247
|
+
} finally{
|
|
248
|
+
try {
|
|
249
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
250
|
+
_iterator.return();
|
|
251
|
+
}
|
|
252
|
+
} finally{
|
|
253
|
+
if (_didIteratorError) {
|
|
254
|
+
throw _iteratorError;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return to;
|
|
9
260
|
};
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
261
|
+
var __toCommonJS = function(mod) {
|
|
262
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
263
|
+
value: true
|
|
264
|
+
}), mod);
|
|
17
265
|
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
266
|
// src/players/FilePlayer.tsx
|
|
21
267
|
var FilePlayer_exports = {};
|
|
22
268
|
__export(FilePlayer_exports, {
|
|
23
|
-
|
|
269
|
+
default: function() {
|
|
270
|
+
return FilePlayer;
|
|
271
|
+
}
|
|
24
272
|
});
|
|
25
273
|
module.exports = __toCommonJS(FilePlayer_exports);
|
|
26
274
|
var import_react = require("react");
|
|
27
|
-
|
|
28
275
|
// src/patterns.ts
|
|
29
276
|
var HLS_EXTENSIONS = /\.(m3u8)($|\?)/i;
|
|
30
277
|
var HLS_PATHS = /\/hls\//i;
|
|
@@ -32,220 +279,304 @@ var DASH_EXTENSIONS = /\.(mpd)($|\?)/i;
|
|
|
32
279
|
var VIDEO_EXTENSIONS = /\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\?)/i;
|
|
33
280
|
var AUDIO_EXTENSIONS = /\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\?)/i;
|
|
34
281
|
var canPlay = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
282
|
+
hls: function(url) {
|
|
283
|
+
if (!url || typeof url !== "string") return false;
|
|
284
|
+
return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);
|
|
285
|
+
},
|
|
286
|
+
dash: function(url) {
|
|
287
|
+
if (!url || typeof url !== "string") return false;
|
|
288
|
+
return DASH_EXTENSIONS.test(url);
|
|
289
|
+
},
|
|
290
|
+
video: function(url) {
|
|
291
|
+
if (!url || typeof url !== "string") return false;
|
|
292
|
+
return VIDEO_EXTENSIONS.test(url);
|
|
293
|
+
},
|
|
294
|
+
audio: function(url) {
|
|
295
|
+
if (!url || typeof url !== "string") return false;
|
|
296
|
+
return AUDIO_EXTENSIONS.test(url);
|
|
297
|
+
},
|
|
298
|
+
file: function(url) {
|
|
299
|
+
if (!url || typeof url !== "string") return false;
|
|
300
|
+
return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);
|
|
301
|
+
}
|
|
55
302
|
};
|
|
56
|
-
|
|
57
303
|
// src/players/FilePlayer.tsx
|
|
58
|
-
var FilePlayer =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
304
|
+
var FilePlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
305
|
+
_inherits(FilePlayer, _import_react_Component);
|
|
306
|
+
function FilePlayer() {
|
|
307
|
+
_class_call_check(this, FilePlayer);
|
|
308
|
+
var _this;
|
|
309
|
+
var _this1, _arguments = arguments;
|
|
310
|
+
_this = _call_super(this, FilePlayer, _to_consumable_array(_arguments)), _this1 = _this;
|
|
311
|
+
_this1.mounted = false;
|
|
312
|
+
_this1.ready = false;
|
|
313
|
+
_this1.load = function() {
|
|
314
|
+
var _this_props_onMount, _this_props;
|
|
315
|
+
if (!_this1.props.videoElement || !_this1.props.src) return;
|
|
316
|
+
var video = _this1.props.videoElement;
|
|
317
|
+
var handleLoadedMetadata = function() {
|
|
318
|
+
if (_this1.mounted && !_this1.ready) {
|
|
319
|
+
var _this_props_onReady, _this_props;
|
|
320
|
+
_this1.ready = true;
|
|
321
|
+
(_this_props_onReady = (_this_props = _this1.props).onReady) === null || _this_props_onReady === void 0 ? void 0 : _this_props_onReady.call(_this_props);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
var handlePlay = function() {
|
|
325
|
+
if (_this1.mounted) {
|
|
326
|
+
var _this_props_onPlay, _this_props;
|
|
327
|
+
(_this_props_onPlay = (_this_props = _this1.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
var handlePause = function() {
|
|
331
|
+
if (_this1.mounted) {
|
|
332
|
+
var _this_props_onPause, _this_props;
|
|
333
|
+
(_this_props_onPause = (_this_props = _this1.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
var handleEnded = function() {
|
|
337
|
+
if (_this1.mounted) {
|
|
338
|
+
var _this_props_onEnded, _this_props;
|
|
339
|
+
(_this_props_onEnded = (_this_props = _this1.props).onEnded) === null || _this_props_onEnded === void 0 ? void 0 : _this_props_onEnded.call(_this_props);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
var handleError = function(error) {
|
|
343
|
+
if (_this1.mounted) {
|
|
344
|
+
var _this_props_onError, _this_props;
|
|
345
|
+
(_this_props_onError = (_this_props = _this1.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var handleLoadedData = function() {
|
|
349
|
+
if (_this1.mounted) {
|
|
350
|
+
var _this_props_onLoaded, _this_props;
|
|
351
|
+
(_this_props_onLoaded = (_this_props = _this1.props).onLoaded) === null || _this_props_onLoaded === void 0 ? void 0 : _this_props_onLoaded.call(_this_props);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
video.addEventListener("loadedmetadata", handleLoadedMetadata);
|
|
355
|
+
video.addEventListener("play", handlePlay);
|
|
356
|
+
video.addEventListener("pause", handlePause);
|
|
357
|
+
video.addEventListener("ended", handleEnded);
|
|
358
|
+
video.addEventListener("error", handleError);
|
|
359
|
+
video.addEventListener("loadeddata", handleLoadedData);
|
|
360
|
+
video.src = _this1.props.src;
|
|
361
|
+
if (_this1.props.autoplay !== void 0) video.autoplay = _this1.props.autoplay;
|
|
362
|
+
if (_this1.props.muted !== void 0) video.muted = _this1.props.muted;
|
|
363
|
+
if (_this1.props.loop !== void 0) video.loop = _this1.props.loop;
|
|
364
|
+
if (_this1.props.controls !== void 0) video.controls = _this1.props.controls;
|
|
365
|
+
if (_this1.props.playsInline !== void 0) video.playsInline = _this1.props.playsInline;
|
|
366
|
+
if (_this1.props.preload !== void 0) video.preload = _this1.props.preload;
|
|
367
|
+
if (_this1.props.poster !== void 0) video.poster = _this1.props.poster;
|
|
368
|
+
(_this_props_onMount = (_this_props = _this1.props).onMount) === null || _this_props_onMount === void 0 ? void 0 : _this_props_onMount.call(_this_props, _this1);
|
|
369
|
+
return function() {
|
|
370
|
+
video.removeEventListener("loadedmetadata", handleLoadedMetadata);
|
|
371
|
+
video.removeEventListener("play", handlePlay);
|
|
372
|
+
video.removeEventListener("pause", handlePause);
|
|
373
|
+
video.removeEventListener("ended", handleEnded);
|
|
374
|
+
video.removeEventListener("error", handleError);
|
|
375
|
+
video.removeEventListener("loadeddata", handleLoadedData);
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
_this1.play = function() {
|
|
379
|
+
if (_this1.props.videoElement) {
|
|
380
|
+
var video = _this1.props.videoElement;
|
|
381
|
+
var hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
|
|
382
|
+
if (hasValidSource) {
|
|
383
|
+
var _video_play;
|
|
384
|
+
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function(error) {
|
|
385
|
+
var _this_props_onError, _this_props;
|
|
386
|
+
console.error("[FilePlayer] Failed to play:", error);
|
|
387
|
+
(_this_props_onError = (_this_props = _this1.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
|
|
388
|
+
});
|
|
389
|
+
} else {
|
|
390
|
+
console.warn("[FilePlayer] Cannot play: video has no valid source");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
_this1.pause = function() {
|
|
395
|
+
if (_this1.props.videoElement) {
|
|
396
|
+
_this1.props.videoElement.pause();
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
_this1.stop = function() {
|
|
400
|
+
_this1.pause();
|
|
401
|
+
if (_this1.props.videoElement) {
|
|
402
|
+
_this1.props.videoElement.currentTime = 0;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
_this1.seekTo = function(seconds, keepPlaying) {
|
|
406
|
+
if (_this1.props.videoElement) {
|
|
407
|
+
_this1.props.videoElement.currentTime = seconds;
|
|
408
|
+
if (!keepPlaying) {
|
|
409
|
+
_this1.pause();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
_this1.setVolume = function(volume) {
|
|
414
|
+
if (_this1.props.videoElement) {
|
|
415
|
+
_this1.props.videoElement.volume = Math.max(0, Math.min(1, volume));
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
_this1.mute = function() {
|
|
419
|
+
if (_this1.props.videoElement) {
|
|
420
|
+
_this1.props.videoElement.muted = true;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
_this1.unmute = function() {
|
|
424
|
+
if (_this1.props.videoElement) {
|
|
425
|
+
_this1.props.videoElement.muted = false;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
_this1.setPlaybackRate = function(rate) {
|
|
429
|
+
if (_this1.props.videoElement && rate > 0) {
|
|
430
|
+
_this1.props.videoElement.playbackRate = rate;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
_this1.setLoop = function(loop) {
|
|
434
|
+
if (_this1.props.videoElement) {
|
|
435
|
+
_this1.props.videoElement.loop = loop;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
_this1.getDuration = function() {
|
|
439
|
+
if (_this1.props.videoElement && isFinite(_this1.props.videoElement.duration)) {
|
|
440
|
+
return _this1.props.videoElement.duration;
|
|
441
|
+
}
|
|
442
|
+
return null;
|
|
443
|
+
};
|
|
444
|
+
_this1.getCurrentTime = function() {
|
|
445
|
+
if (_this1.props.videoElement && isFinite(_this1.props.videoElement.currentTime)) {
|
|
446
|
+
return _this1.props.videoElement.currentTime;
|
|
447
|
+
}
|
|
448
|
+
return null;
|
|
449
|
+
};
|
|
450
|
+
_this1.getSecondsLoaded = function() {
|
|
451
|
+
if (_this1.props.videoElement && _this1.props.videoElement.buffered.length > 0) {
|
|
452
|
+
return _this1.props.videoElement.buffered.end(_this1.props.videoElement.buffered.length - 1);
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
};
|
|
456
|
+
_this1.getInternalPlayer = function() {
|
|
457
|
+
var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "player";
|
|
458
|
+
if (key === "video") return _this1.props.videoElement;
|
|
459
|
+
return null;
|
|
460
|
+
};
|
|
461
|
+
_this1.enablePIP = function() {
|
|
462
|
+
return _async_to_generator(function() {
|
|
463
|
+
var error;
|
|
464
|
+
return _ts_generator(this, function(_state) {
|
|
465
|
+
switch(_state.label){
|
|
466
|
+
case 0:
|
|
467
|
+
if (!(_this1.props.videoElement && "requestPictureInPicture" in _this1.props.videoElement)) return [
|
|
468
|
+
3,
|
|
469
|
+
4
|
|
470
|
+
];
|
|
471
|
+
_state.label = 1;
|
|
472
|
+
case 1:
|
|
473
|
+
_state.trys.push([
|
|
474
|
+
1,
|
|
475
|
+
3,
|
|
476
|
+
,
|
|
477
|
+
4
|
|
478
|
+
]);
|
|
479
|
+
return [
|
|
480
|
+
4,
|
|
481
|
+
_this1.props.videoElement.requestPictureInPicture()
|
|
482
|
+
];
|
|
483
|
+
case 2:
|
|
484
|
+
_state.sent();
|
|
485
|
+
return [
|
|
486
|
+
3,
|
|
487
|
+
4
|
|
488
|
+
];
|
|
489
|
+
case 3:
|
|
490
|
+
error = _state.sent();
|
|
491
|
+
console.warn("Picture-in-Picture failed:", error);
|
|
492
|
+
return [
|
|
493
|
+
3,
|
|
494
|
+
4
|
|
495
|
+
];
|
|
496
|
+
case 4:
|
|
497
|
+
return [
|
|
498
|
+
2
|
|
499
|
+
];
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
})();
|
|
503
|
+
};
|
|
504
|
+
_this1.disablePIP = function() {
|
|
505
|
+
return _async_to_generator(function() {
|
|
506
|
+
var error;
|
|
507
|
+
return _ts_generator(this, function(_state) {
|
|
508
|
+
switch(_state.label){
|
|
509
|
+
case 0:
|
|
510
|
+
if (!document.pictureInPictureElement) return [
|
|
511
|
+
3,
|
|
512
|
+
4
|
|
513
|
+
];
|
|
514
|
+
_state.label = 1;
|
|
515
|
+
case 1:
|
|
516
|
+
_state.trys.push([
|
|
517
|
+
1,
|
|
518
|
+
3,
|
|
519
|
+
,
|
|
520
|
+
4
|
|
521
|
+
]);
|
|
522
|
+
return [
|
|
523
|
+
4,
|
|
524
|
+
document.exitPictureInPicture()
|
|
525
|
+
];
|
|
526
|
+
case 2:
|
|
527
|
+
_state.sent();
|
|
528
|
+
return [
|
|
529
|
+
3,
|
|
530
|
+
4
|
|
531
|
+
];
|
|
532
|
+
case 3:
|
|
533
|
+
error = _state.sent();
|
|
534
|
+
console.warn("Exit Picture-in-Picture failed:", error);
|
|
535
|
+
return [
|
|
536
|
+
3,
|
|
537
|
+
4
|
|
538
|
+
];
|
|
539
|
+
case 4:
|
|
540
|
+
return [
|
|
541
|
+
2
|
|
542
|
+
];
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
})();
|
|
546
|
+
};
|
|
547
|
+
return _this;
|
|
243
548
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
549
|
+
_create_class(FilePlayer, [
|
|
550
|
+
{
|
|
551
|
+
key: "componentDidMount",
|
|
552
|
+
value: function componentDidMount() {
|
|
553
|
+
this.mounted = true;
|
|
554
|
+
this.load();
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
key: "componentWillUnmount",
|
|
559
|
+
value: function componentWillUnmount() {
|
|
560
|
+
this.mounted = false;
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
key: "componentDidUpdate",
|
|
565
|
+
value: function componentDidUpdate(prevProps) {
|
|
566
|
+
if (prevProps.src !== this.props.src) {
|
|
567
|
+
this.load();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
key: "render",
|
|
573
|
+
value: function render() {
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
]);
|
|
578
|
+
return FilePlayer;
|
|
579
|
+
}(import_react.Component);
|
|
249
580
|
FilePlayer.displayName = "FilePlayer";
|
|
250
581
|
FilePlayer.canPlay = canPlay.file;
|
|
251
582
|
//# sourceMappingURL=FilePlayer.cjs.map
|