@micromag/element-video 0.3.117 → 0.3.119

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 CHANGED
@@ -184,8 +184,7 @@ var Video = function Video(_ref) {
184
184
  apiRef.current.mediaRef = ref;
185
185
  }
186
186
 
187
- var playing = api.playing,
188
- muted = api.muted,
187
+ var muted = api.muted,
189
188
  dataReady = api.dataReady,
190
189
  play = api.play,
191
190
  pause = api.pause,
@@ -209,21 +208,23 @@ var Video = function Video(_ref) {
209
208
  }, [autoPlay]); // Ensure load if preload value change over time
210
209
 
211
210
  var firstPreloadRef = useRef(preload);
212
- var hasLoadedRef = useRef(preload !== 'none' && preload !== 'metadata');
211
+ var firstShouldLoadRef = useRef(shouldLoad);
212
+ var hasLoadedRef = useRef(preload !== 'none' && preload !== 'metadata' && shouldLoad);
213
213
  useEffect(function () {
214
214
  var _ref$current = ref.current,
215
215
  videoElement = _ref$current === void 0 ? null : _ref$current;
216
216
  var canLoad = preload !== 'none' && preload !== 'metadata' && shouldLoad; // @todo
217
217
 
218
218
  var preloadHasChanged = firstPreloadRef.current !== preload;
219
+ var shouldLoadHasChanged = firstShouldLoadRef.current !== shouldLoad;
219
220
 
220
- if (canLoad && preloadHasChanged && !hasLoadedRef.current && videoElement !== null && typeof videoElement.load !== 'undefined') {
221
+ if (canLoad && (preloadHasChanged || shouldLoadHasChanged) && !hasLoadedRef.current && videoElement !== null && typeof videoElement.load !== 'undefined') {
221
222
  hasLoadedRef.current = true;
222
223
  videoElement.load();
223
224
  }
224
225
  }, [shouldLoad, preload]);
225
226
  return /*#__PURE__*/React.createElement("div", {
226
- className: classNames([styles.container, (_ref7 = {}, _defineProperty(_ref7, className, className !== null), _defineProperty(_ref7, styles.paused, !playing), _defineProperty(_ref7, styles.withSize, withSize), _ref7)]),
227
+ className: classNames([styles.container, (_ref7 = {}, _defineProperty(_ref7, className, className !== null), _defineProperty(_ref7, styles.withSize, withSize), _ref7)]),
227
228
  style: withSize ? {
228
229
  width: width,
229
230
  height: height
@@ -235,12 +236,12 @@ var Video = function Video(_ref) {
235
236
  }) : null, !isImageWithoutSourceFile ? /*#__PURE__*/React.createElement("video", {
236
237
  key: mediaUrl,
237
238
  ref: ref,
238
- src: sourceFiles === null ? mediaUrl : null,
239
+ src: sourceFiles === null || sourceFiles.length === 0 ? mediaUrl : null,
239
240
  autoPlay: autoPlay,
240
241
  loop: loop,
241
242
  muted: muted,
242
243
  poster: shouldLoad ? thumbnailUrl : null,
243
- preload: shouldLoad ? preload : 'metadata',
244
+ preload: shouldLoad ? preload : 'none',
244
245
  playsInline: playsInline,
245
246
  crossOrigin: withoutCors ? 'anonymous' : null,
246
247
  tabIndex: focusable ? '0' : '-1',
package/lib/index.js CHANGED
@@ -195,8 +195,7 @@ var Video = function Video(_ref) {
195
195
  apiRef.current.mediaRef = ref;
196
196
  }
197
197
 
198
- var playing = api.playing,
199
- muted = api.muted,
198
+ var muted = api.muted,
200
199
  dataReady = api.dataReady,
201
200
  play = api.play,
202
201
  pause = api.pause,
@@ -220,21 +219,23 @@ var Video = function Video(_ref) {
220
219
  }, [autoPlay]); // Ensure load if preload value change over time
221
220
 
222
221
  var firstPreloadRef = React.useRef(preload);
223
- var hasLoadedRef = React.useRef(preload !== 'none' && preload !== 'metadata');
222
+ var firstShouldLoadRef = React.useRef(shouldLoad);
223
+ var hasLoadedRef = React.useRef(preload !== 'none' && preload !== 'metadata' && shouldLoad);
224
224
  React.useEffect(function () {
225
225
  var _ref$current = ref.current,
226
226
  videoElement = _ref$current === void 0 ? null : _ref$current;
227
227
  var canLoad = preload !== 'none' && preload !== 'metadata' && shouldLoad; // @todo
228
228
 
229
229
  var preloadHasChanged = firstPreloadRef.current !== preload;
230
+ var shouldLoadHasChanged = firstShouldLoadRef.current !== shouldLoad;
230
231
 
231
- if (canLoad && preloadHasChanged && !hasLoadedRef.current && videoElement !== null && typeof videoElement.load !== 'undefined') {
232
+ if (canLoad && (preloadHasChanged || shouldLoadHasChanged) && !hasLoadedRef.current && videoElement !== null && typeof videoElement.load !== 'undefined') {
232
233
  hasLoadedRef.current = true;
233
234
  videoElement.load();
234
235
  }
235
236
  }, [shouldLoad, preload]);
236
237
  return /*#__PURE__*/React__default["default"].createElement("div", {
237
- className: classNames__default["default"]([styles.container, (_ref7 = {}, _defineProperty__default["default"](_ref7, className, className !== null), _defineProperty__default["default"](_ref7, styles.paused, !playing), _defineProperty__default["default"](_ref7, styles.withSize, withSize), _ref7)]),
238
+ className: classNames__default["default"]([styles.container, (_ref7 = {}, _defineProperty__default["default"](_ref7, className, className !== null), _defineProperty__default["default"](_ref7, styles.withSize, withSize), _ref7)]),
238
239
  style: withSize ? {
239
240
  width: width,
240
241
  height: height
@@ -246,12 +247,12 @@ var Video = function Video(_ref) {
246
247
  }) : null, !isImageWithoutSourceFile ? /*#__PURE__*/React__default["default"].createElement("video", {
247
248
  key: mediaUrl,
248
249
  ref: ref,
249
- src: sourceFiles === null ? mediaUrl : null,
250
+ src: sourceFiles === null || sourceFiles.length === 0 ? mediaUrl : null,
250
251
  autoPlay: autoPlay,
251
252
  loop: loop,
252
253
  muted: muted,
253
254
  poster: shouldLoad ? thumbnailUrl : null,
254
- preload: shouldLoad ? preload : 'metadata',
255
+ preload: shouldLoad ? preload : 'none',
255
256
  playsInline: playsInline,
256
257
  crossOrigin: withoutCors ? 'anonymous' : null,
257
258
  tabIndex: focusable ? '0' : '-1',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-video",
3
- "version": "0.3.117",
3
+ "version": "0.3.119",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,9 +52,9 @@
52
52
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
53
53
  "@fortawesome/free-solid-svg-icons": "^5.15.1",
54
54
  "@fortawesome/react-fontawesome": "^0.1.13",
55
- "@micromag/core": "^0.3.117",
56
- "@micromag/element-closed-captions": "^0.3.117",
57
- "@micromag/element-media-controls": "^0.3.117",
55
+ "@micromag/core": "^0.3.119",
56
+ "@micromag/element-closed-captions": "^0.3.119",
57
+ "@micromag/element-media-controls": "^0.3.119",
58
58
  "classnames": "^2.2.6",
59
59
  "prop-types": "^15.7.2",
60
60
  "react-intl": "^5.12.1",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "eab1c9a0b8c19d747fee6472158779f33b1f18d3"
66
+ "gitHead": "009841dc1641be98ddce6ed56cfcddc22509f342"
67
67
  }