@micromag/screen-video-360 0.4.69 → 0.4.71

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.d.ts +2 -1
  2. package/es/index.js +10 -11
  3. package/package.json +11 -11
package/es/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ForwardedRef } from 'react';
2
3
  import { VideoElement, Header, Footer, BackgroundElement } from '@micromag/core';
3
4
 
4
5
  interface Video360ScreenProps {
@@ -11,7 +12,7 @@ interface Video360ScreenProps {
11
12
  preload?: boolean;
12
13
  type?: string | null;
13
14
  spacing?: number;
14
- mediaRef?: ((...args: unknown[]) => void) | null;
15
+ mediaRef?: ForwardedRef<HTMLMediaElement> | null;
15
16
  className?: string | null;
16
17
  }
17
18
  declare function Video360Screen({ layout: _layout, video, header, footer, background, current, preload, type, spacing, mediaRef: customMediaRef, className, }: Video360ScreenProps): react_jsx_runtime.JSX.Element;
package/es/index.js CHANGED
@@ -6,9 +6,9 @@ import { getSizeWithinBounds } from '@folklore/size';
6
6
  import classNames from 'classnames';
7
7
  import { useState, useEffect, useRef, useCallback } from 'react';
8
8
  import { ScreenElement, PlaceholderVideo360 } from '@micromag/core/components';
9
- import { useViewerInteraction, useViewerNavigation, useViewerContext, useScreenSize, useScreenRenderContext, useViewerWebView, usePlaybackContext, useViewerContainer } from '@micromag/core/contexts';
9
+ import { useViewerInteraction, useViewerNavigation, useViewerContext, useScreenSize, useScreenRenderContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef, useViewerContainer } from '@micromag/core/contexts';
10
10
  import { useTrackScreenEvent, useTrackScreenMedia, useDevicePixelRatio, useActivityDetector, useDebounce, useAnimationFrame } from '@micromag/core/hooks';
11
- import { isHeaderFilled, isFooterFilled, getFooterProps } from '@micromag/core/utils';
11
+ import { isHeaderFilled, isFooterFilled, getFooterProps, mergeRefs } from '@micromag/core/utils';
12
12
  import Background from '@micromag/element-background';
13
13
  import ClosedCaptions from '@micromag/element-closed-captions';
14
14
  import Container from '@micromag/element-container';
@@ -121,7 +121,6 @@ function Video360Screen(_ref) {
121
121
  var _useViewerWebView = useViewerWebView(),
122
122
  openWebView = _useViewerWebView.open;
123
123
  var devicePixelRatio = useDevicePixelRatio();
124
- var backgroundPlaying = current && (isView || isEdit);
125
124
  var mediaShouldLoad = current || preload;
126
125
  var _ref2 = video || {},
127
126
  _ref2$media = _ref2.media,
@@ -153,7 +152,12 @@ function Video360Screen(_ref) {
153
152
  hideControls = _usePlaybackContext.hideControls,
154
153
  currentQualityLevel = _usePlaybackContext.currentQualityLevel,
155
154
  setCurrentQualityLevel = _usePlaybackContext.setCurrentQualityLevel;
156
- var mediaRef = useRef(null);
155
+ var _usePlaybackMediaRef = usePlaybackMediaRef(current),
156
+ mediaRef = _usePlaybackMediaRef.ref,
157
+ _usePlaybackMediaRef$ = _usePlaybackMediaRef.isCurrent,
158
+ isCurrentMedia = _usePlaybackMediaRef$ === void 0 ? false : _usePlaybackMediaRef$;
159
+ var backgroundPlaying = current && (isView || isEdit) && (isCurrentMedia || !isView);
160
+ var videoPlaying = current && (isView || isEdit) && playing && (isCurrentMedia || !isView);
157
161
  useEffect(function () {
158
162
  if (!current) {
159
163
  return function () {};
@@ -183,11 +187,6 @@ function Video360Screen(_ref) {
183
187
  setMedia(null);
184
188
  };
185
189
  }, [current]);
186
- useEffect(function () {
187
- if (customMediaRef !== null) {
188
- customMediaRef(mediaRef.current);
189
- }
190
- }, [mediaRef.current]);
191
190
  useEffect(function () {
192
191
  if (current && autoPlay && !playing) {
193
192
  setPlaying(true);
@@ -521,9 +520,9 @@ function Video360Screen(_ref) {
521
520
  top: resizedVideoTop
522
521
  },
523
522
  children: /*#__PURE__*/jsx(Video, _objectSpread(_objectSpread({}, finalVideo), {}, {
524
- mediaRef: mediaRef,
523
+ mediaRef: mergeRefs(mediaRef, customMediaRef),
525
524
  className: styles.video,
526
- paused: !current || !playing,
525
+ paused: !videoPlaying,
527
526
  muted: muted,
528
527
  withoutCors: true,
529
528
  onReady: onVideoReady,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-video-360",
3
- "version": "0.4.69",
3
+ "version": "0.4.71",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -62,15 +62,15 @@
62
62
  "dependencies": {
63
63
  "@babel/runtime": "^7.28.6",
64
64
  "@folklore/size": "^0.1.20",
65
- "@micromag/core": "^0.4.69",
66
- "@micromag/element-background": "^0.4.69",
67
- "@micromag/element-closed-captions": "^0.4.69",
68
- "@micromag/element-container": "^0.4.69",
69
- "@micromag/element-footer": "^0.4.69",
70
- "@micromag/element-header": "^0.4.69",
71
- "@micromag/element-image": "^0.4.69",
72
- "@micromag/element-video": "^0.4.69",
73
- "@micromag/transforms": "^0.4.69",
65
+ "@micromag/core": "^0.4.71",
66
+ "@micromag/element-background": "^0.4.71",
67
+ "@micromag/element-closed-captions": "^0.4.71",
68
+ "@micromag/element-container": "^0.4.71",
69
+ "@micromag/element-footer": "^0.4.71",
70
+ "@micromag/element-header": "^0.4.71",
71
+ "@micromag/element-image": "^0.4.71",
72
+ "@micromag/element-video": "^0.4.71",
73
+ "@micromag/transforms": "^0.4.71",
74
74
  "classnames": "^2.2.6",
75
75
  "lodash": "^4.17.23",
76
76
  "react-intl": "^8.1.3 || ^10.0.0",
@@ -81,6 +81,6 @@
81
81
  "access": "public",
82
82
  "registry": "https://registry.npmjs.org/"
83
83
  },
84
- "gitHead": "509e113dc06022d6092e4aac9f47ccd5facfd59d",
84
+ "gitHead": "9101554bc5761e32b4a002a10d26800608c69773",
85
85
  "types": "es/index.d.ts"
86
86
  }