@micromag/element-video 0.4.69 → 0.4.70

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 +12 -14
  2. package/package.json +2 -2
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';
10
9
  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,40 +250,38 @@ function Video(_ref) {
250
250
  onReady();
251
251
  }
252
252
  }, [ready, onReady]);
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];
253
+ var finalPreload = shouldLoad ? preload : 'none';
254
+ var _useState5 = useState(finalPreload === 'auto' || finalPreload === 'metadata'),
255
+ _useState6 = _slicedToArray(_useState5, 2),
256
+ wasPreloaded = _useState6[0],
257
+ setWasPreloaded = _useState6[1];
260
258
  useEffect(function () {
261
259
  var _ref$current2 = _ref6.current,
262
260
  element = _ref$current2 === void 0 ? null : _ref$current2;
263
- if (element !== null && shouldLoad && (!wasPreloaded || element.readyState === 0)) {
261
+ if (shouldLoad && !wasPreloaded && element !== null) {
264
262
  try {
265
263
  element.load();
266
264
  } catch (_unused) {}
267
265
  setWasPreloaded(true);
268
266
  }
269
- }, [shouldLoad, wasPreloaded, mediaUrl, paused]);
267
+ }, [shouldLoad, wasPreloaded]);
270
268
  useEffect(function () {
271
269
  var _ref$current3 = _ref6.current,
272
270
  element = _ref$current3 === void 0 ? null : _ref$current3;
273
271
  if (element === null || mediaUrl === null) {
274
272
  return;
275
273
  }
276
- var isPlaying = mediaElementIsPlaying(element);
277
- if (paused && isPlaying) {
274
+ var isPaused = element.paused;
275
+ if (paused && !isPaused) {
278
276
  element.pause();
279
- } else if (!paused && !isPlaying) {
277
+ } else if (!paused && isPaused) {
280
278
  element.play()["catch"](function (e) {
281
279
  if (onPlayError !== null) {
282
280
  onPlayError(e);
283
281
  }
284
282
  });
285
283
  }
286
- }, [paused, media, mediaUrl, shouldLoad, wasPreloaded]);
284
+ }, [paused, media, mediaUrl, onPlayError]);
287
285
  useProgressSteps({
288
286
  currentTime: currentTime,
289
287
  duration: duration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-video",
3
- "version": "0.4.69",
3
+ "version": "0.4.70",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -72,6 +72,6 @@
72
72
  "access": "public",
73
73
  "registry": "https://registry.npmjs.org/"
74
74
  },
75
- "gitHead": "509e113dc06022d6092e4aac9f47ccd5facfd59d",
75
+ "gitHead": "4f76a8f1ad594be2aadb4a593da5455da8afc8b6",
76
76
  "types": "es/index.d.ts"
77
77
  }