@micromag/element-video 0.4.66 → 0.4.69
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 +14 -12
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import classNames from 'classnames';
|
|
|
6
6
|
import isFunction from 'lodash/isFunction';
|
|
7
7
|
import { useMemo, useState, useEffect, useRef, useCallback } from 'react';
|
|
8
8
|
import { Spinner } from '@micromag/core/components';
|
|
9
|
+
import { useSetting, mediaElementIsPlaying } from '@micromag/core/contexts';
|
|
9
10
|
import { useMediaThumbnail, useMediaCurrentTime, useMediaDuration, useMediaReady, useProgressSteps } from '@micromag/core/hooks';
|
|
10
|
-
import { useSetting } from '@micromag/core/contexts';
|
|
11
11
|
import { getMediaFilesAsArray, getVideoSupportedMimes } from '@micromag/core/utils';
|
|
12
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
13
|
|
|
@@ -250,38 +250,40 @@ function Video(_ref) {
|
|
|
250
250
|
onReady();
|
|
251
251
|
}
|
|
252
252
|
}, [ready, onReady]);
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
253
|
+
var _useState5 = useState(shouldLoad ? preload : 'none'),
|
|
254
|
+
_useState6 = _slicedToArray(_useState5, 1),
|
|
255
|
+
finalPreload = _useState6[0];
|
|
256
|
+
var _useState7 = useState(finalPreload === 'auto' || finalPreload === 'metadata'),
|
|
257
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
258
|
+
wasPreloaded = _useState8[0],
|
|
259
|
+
setWasPreloaded = _useState8[1];
|
|
258
260
|
useEffect(function () {
|
|
259
261
|
var _ref$current2 = _ref6.current,
|
|
260
262
|
element = _ref$current2 === void 0 ? null : _ref$current2;
|
|
261
|
-
if (shouldLoad && !wasPreloaded
|
|
263
|
+
if (element !== null && shouldLoad && (!wasPreloaded || element.readyState === 0)) {
|
|
262
264
|
try {
|
|
263
265
|
element.load();
|
|
264
266
|
} catch (_unused) {}
|
|
265
267
|
setWasPreloaded(true);
|
|
266
268
|
}
|
|
267
|
-
}, [shouldLoad, wasPreloaded]);
|
|
269
|
+
}, [shouldLoad, wasPreloaded, mediaUrl, paused]);
|
|
268
270
|
useEffect(function () {
|
|
269
271
|
var _ref$current3 = _ref6.current,
|
|
270
272
|
element = _ref$current3 === void 0 ? null : _ref$current3;
|
|
271
273
|
if (element === null || mediaUrl === null) {
|
|
272
274
|
return;
|
|
273
275
|
}
|
|
274
|
-
var
|
|
275
|
-
if (paused &&
|
|
276
|
+
var isPlaying = mediaElementIsPlaying(element);
|
|
277
|
+
if (paused && isPlaying) {
|
|
276
278
|
element.pause();
|
|
277
|
-
} else if (!paused &&
|
|
279
|
+
} else if (!paused && !isPlaying) {
|
|
278
280
|
element.play()["catch"](function (e) {
|
|
279
281
|
if (onPlayError !== null) {
|
|
280
282
|
onPlayError(e);
|
|
281
283
|
}
|
|
282
284
|
});
|
|
283
285
|
}
|
|
284
|
-
}, [paused, media, mediaUrl,
|
|
286
|
+
}, [paused, media, mediaUrl, shouldLoad, wasPreloaded]);
|
|
285
287
|
useProgressSteps({
|
|
286
288
|
currentTime: currentTime,
|
|
287
289
|
duration: duration,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-video",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.69",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@babel/runtime": "^7.28.6",
|
|
63
|
-
"@micromag/core": "^0.4.
|
|
64
|
-
"@micromag/element-closed-captions": "^0.4.
|
|
63
|
+
"@micromag/core": "^0.4.69",
|
|
64
|
+
"@micromag/element-closed-captions": "^0.4.69",
|
|
65
65
|
"classnames": "^2.2.6",
|
|
66
66
|
"hls.js": "^1.5.15",
|
|
67
67
|
"lodash": "^4.17.23",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"access": "public",
|
|
73
73
|
"registry": "https://registry.npmjs.org/"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "509e113dc06022d6092e4aac9f47ccd5facfd59d",
|
|
76
76
|
"types": "es/index.d.ts"
|
|
77
77
|
}
|