@micromag/element-video 0.3.590 → 0.3.592
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/es/index.js +25 -5
- package/package.json +2 -2
package/es/index.js
CHANGED
|
@@ -196,14 +196,20 @@ var Video = function Video(_ref) {
|
|
|
196
196
|
useEffect(function () {
|
|
197
197
|
setHlsTsOffset(0);
|
|
198
198
|
setHlsFailed(false);
|
|
199
|
-
if (!shouldLoad ||
|
|
199
|
+
if (!shouldLoad || hlsSources === null || hlsSources.length === 0) {
|
|
200
200
|
setHlsJs(null);
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
var hls = new Hls({
|
|
204
204
|
maxBufferLength: 15,
|
|
205
205
|
// seconds. prevents loading too much per screen.
|
|
206
|
-
startLevel: qualityStartLevel !== null ? qualityStartLevel : -1
|
|
206
|
+
startLevel: qualityStartLevel !== null ? qualityStartLevel : -1,
|
|
207
|
+
enableWorker: true
|
|
208
|
+
// debug: true,
|
|
209
|
+
// lowLatencyMode: true,
|
|
210
|
+
// backBufferLength: 90,
|
|
211
|
+
// testBandwidth: qualityStartLevel === null,
|
|
212
|
+
// startFragPrefetch: true,
|
|
207
213
|
});
|
|
208
214
|
hls.on(Hls.Events.LEVEL_SWITCHED, function (_, _ref5) {
|
|
209
215
|
var level = _ref5.level;
|
|
@@ -250,21 +256,35 @@ var Video = function Video(_ref) {
|
|
|
250
256
|
hls.on(Hls.Events.BUFFER_APPENDED, _onHlsBufferAppended);
|
|
251
257
|
hls.loadSource(hlsSources[0].url);
|
|
252
258
|
setHlsJs(hls);
|
|
253
|
-
}, [shouldLoad, hlsSources
|
|
259
|
+
}, [shouldLoad, hlsSources]);
|
|
254
260
|
|
|
255
|
-
// attach hls.js when the <video> ref is ready
|
|
261
|
+
// attach hls.js when the <video> ref or the hls.js instance is ready
|
|
256
262
|
useEffect(function () {
|
|
257
263
|
if (hlsJs !== null && _ref16.current !== null) {
|
|
258
264
|
hlsJs.attachMedia(_ref16.current);
|
|
265
|
+
// if (onQualityLevelChange !== null) {
|
|
266
|
+
// onQualityLevelChange(hlsJs.currentLevel, ref.current);
|
|
267
|
+
// }
|
|
259
268
|
}
|
|
260
269
|
return function () {
|
|
261
270
|
if (hlsJs !== null) {
|
|
262
271
|
hlsJs.detachMedia();
|
|
263
|
-
hlsJs.destroy();
|
|
264
272
|
}
|
|
265
273
|
};
|
|
266
274
|
}, [hlsJs, _ref16.current]);
|
|
267
275
|
|
|
276
|
+
// cleanup hls.js instance when it is no longer needed
|
|
277
|
+
useEffect(function () {
|
|
278
|
+
return (
|
|
279
|
+
// teardown func
|
|
280
|
+
function () {
|
|
281
|
+
if (hlsJs !== null) {
|
|
282
|
+
hlsJs.destroy();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}, [hlsJs]);
|
|
287
|
+
|
|
268
288
|
// handle changes of qualityStartLevel when an hls.js instance exists
|
|
269
289
|
useEffect(function () {
|
|
270
290
|
if (hlsJs !== null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-video",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.592",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"access": "public",
|
|
73
73
|
"registry": "https://registry.npmjs.org/"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "f8571e100614efa926df27062058faee906df21e"
|
|
76
76
|
}
|