@micromag/screen-video 0.3.144 → 0.3.147

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 (3) hide show
  1. package/es/index.js +19 -13
  2. package/lib/index.js +19 -13
  3. package/package.json +11 -11
package/es/index.js CHANGED
@@ -288,25 +288,31 @@ var VideoScreen = function VideoScreen(_ref) {
288
288
  }, [videoUrl, hasVideoUrl, setReady]);
289
289
  var onVideoReady = useCallback(function () {
290
290
  setReady(true);
291
- }, [setReady]); // @todo trying to see if it's a better strategy than using `onSuspended`
292
-
293
- var AUTOPLAY_CHECK_DELAY = 1000; // @todo check if a timeout is needed?
291
+ }, [setReady]);
292
+ /**
293
+ * if video can play, but:
294
+ * - it's the current screen
295
+ * - the video doesn't provide visual controls
296
+ * - the video is set to play automatically
297
+ * - and it's **not** playing
298
+ * -> then set up a button that catches a click and plays the video
299
+ */
294
300
 
295
301
  var onCanPlay = useCallback(function () {
296
- var autoplayCheckTimeout = setTimeout(function () {
297
- if (current && autoPlay && !playing) {
298
- setAllowManualPlayOnTap(true);
299
- }
300
- }, AUTOPLAY_CHECK_DELAY);
301
- return function () {
302
- return clearTimeout(autoplayCheckTimeout);
303
- };
304
- }, [current, autoPlay, playing, play, allowManualPlayOnTap, setAllowManualPlayOnTap]);
302
+ if (current && !withControls && autoPlay && !playing) {
303
+ setAllowManualPlayOnTap(true);
304
+ }
305
+ }, [current, withControls, autoPlay, playing, play, allowManualPlayOnTap, setAllowManualPlayOnTap]);
306
+ var onForcePlay = useCallback(function (e) {
307
+ e.stopPropagation();
308
+ setAllowManualPlayOnTap(false);
309
+ play();
310
+ }, [setAllowManualPlayOnTap, play]);
305
311
  var visibleControls = !autoPlay && !playing || muted || showMediaControls;
306
312
  var items = [allowManualPlayOnTap ? /*#__PURE__*/React.createElement("button", {
307
313
  key: "tap-catcher-button",
308
314
  type: "button",
309
- onTouchStart: play,
315
+ onClick: onForcePlay,
310
316
  className: styles.unmuteAndPlayButton
311
317
  }) : null, /*#__PURE__*/React.createElement(ScreenElement, {
312
318
  key: "video",
package/lib/index.js CHANGED
@@ -309,25 +309,31 @@ var VideoScreen = function VideoScreen(_ref) {
309
309
  }, [videoUrl, hasVideoUrl, setReady]);
310
310
  var onVideoReady = React.useCallback(function () {
311
311
  setReady(true);
312
- }, [setReady]); // @todo trying to see if it's a better strategy than using `onSuspended`
313
-
314
- var AUTOPLAY_CHECK_DELAY = 1000; // @todo check if a timeout is needed?
312
+ }, [setReady]);
313
+ /**
314
+ * if video can play, but:
315
+ * - it's the current screen
316
+ * - the video doesn't provide visual controls
317
+ * - the video is set to play automatically
318
+ * - and it's **not** playing
319
+ * -> then set up a button that catches a click and plays the video
320
+ */
315
321
 
316
322
  var onCanPlay = React.useCallback(function () {
317
- var autoplayCheckTimeout = setTimeout(function () {
318
- if (current && autoPlay && !playing) {
319
- setAllowManualPlayOnTap(true);
320
- }
321
- }, AUTOPLAY_CHECK_DELAY);
322
- return function () {
323
- return clearTimeout(autoplayCheckTimeout);
324
- };
325
- }, [current, autoPlay, playing, play, allowManualPlayOnTap, setAllowManualPlayOnTap]);
323
+ if (current && !withControls && autoPlay && !playing) {
324
+ setAllowManualPlayOnTap(true);
325
+ }
326
+ }, [current, withControls, autoPlay, playing, play, allowManualPlayOnTap, setAllowManualPlayOnTap]);
327
+ var onForcePlay = React.useCallback(function (e) {
328
+ e.stopPropagation();
329
+ setAllowManualPlayOnTap(false);
330
+ play();
331
+ }, [setAllowManualPlayOnTap, play]);
326
332
  var visibleControls = !autoPlay && !playing || muted || showMediaControls;
327
333
  var items = [allowManualPlayOnTap ? /*#__PURE__*/React__default["default"].createElement("button", {
328
334
  key: "tap-catcher-button",
329
335
  type: "button",
330
- onTouchStart: play,
336
+ onClick: onForcePlay,
331
337
  className: styles.unmuteAndPlayButton
332
338
  }) : null, /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
333
339
  key: "video",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-video",
3
- "version": "0.3.144",
3
+ "version": "0.3.147",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -50,15 +50,15 @@
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.13.10",
52
52
  "@folklore/size": "^0.1.20",
53
- "@micromag/core": "^0.3.144",
54
- "@micromag/element-background": "^0.3.144",
55
- "@micromag/element-call-to-action": "^0.3.144",
56
- "@micromag/element-closed-captions": "^0.3.144",
57
- "@micromag/element-container": "^0.3.144",
58
- "@micromag/element-image": "^0.3.144",
59
- "@micromag/element-media-controls": "^0.3.144",
60
- "@micromag/element-video": "^0.3.144",
61
- "@micromag/transforms": "^0.3.144",
53
+ "@micromag/core": "^0.3.147",
54
+ "@micromag/element-background": "^0.3.147",
55
+ "@micromag/element-call-to-action": "^0.3.147",
56
+ "@micromag/element-closed-captions": "^0.3.147",
57
+ "@micromag/element-container": "^0.3.147",
58
+ "@micromag/element-image": "^0.3.147",
59
+ "@micromag/element-media-controls": "^0.3.147",
60
+ "@micromag/element-video": "^0.3.147",
61
+ "@micromag/transforms": "^0.3.147",
62
62
  "classnames": "^2.2.6",
63
63
  "lodash": "^4.17.21",
64
64
  "prop-types": "^15.7.2",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "d0f88b972312c6f728601a828b7ab98fd396dfee"
71
+ "gitHead": "695a66acc54f4863dc44a98f0471e8233ca10aee"
72
72
  }