@micromag/element-video 0.3.590 → 0.3.591

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 (2) hide show
  1. package/es/index.js +26 -6
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -64,7 +64,7 @@ var defaultProps = {
64
64
  playsInline: true,
65
65
  preload: 'auto',
66
66
  disablePictureInPicture: true,
67
- disableHls: true,
67
+ disableHls: false,
68
68
  shouldLoad: true,
69
69
  withoutCors: false,
70
70
  className: null,
@@ -196,14 +196,20 @@ var Video = function Video(_ref) {
196
196
  useEffect(function () {
197
197
  setHlsTsOffset(0);
198
198
  setHlsFailed(false);
199
- if (!shouldLoad || _ref16.current === null || hlsSources === null || hlsSources.length === 0) {
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, _ref16]);
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.590",
3
+ "version": "0.3.591",
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": "aee5033c29da327111287f71fd59cb77f469306a"
75
+ "gitHead": "408109a7ecf28442e75871359a3a9cba22e06344"
76
76
  }