@micromag/screen-video-360 0.3.541 → 0.3.569

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 +2 -3
  2. package/package.json +12 -13
  3. package/lib/index.js +0 -727
package/es/index.js CHANGED
@@ -627,7 +627,6 @@ var Video360Screen = function Video360Screen(_ref) {
627
627
  };
628
628
  Video360Screen.propTypes = propTypes;
629
629
  Video360Screen.defaultProps = defaultProps;
630
- var Video360Screen$1 = Video360Screen;
631
630
 
632
631
  // import * as transforms from './transforms/index';
633
632
 
@@ -651,7 +650,7 @@ var definition = {
651
650
  "value": "360 Video"
652
651
  }]
653
652
  }),
654
- component: Video360Screen$1,
653
+ component: Video360Screen,
655
654
  layouts: ['full'],
656
655
  // transforms,
657
656
  fields: [{
@@ -719,4 +718,4 @@ var definition = {
719
718
  }]
720
719
  };
721
720
 
722
- export { Video360Screen$1 as Video360Screen, definition as default };
721
+ export { Video360Screen, definition as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-video-360",
3
- "version": "0.3.541",
3
+ "version": "0.3.569",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -30,12 +30,11 @@
30
30
  }
31
31
  ],
32
32
  "license": "ISC",
33
- "main": "lib/index.js",
33
+ "type": "module",
34
34
  "module": "es/index.js",
35
35
  "style": "assets/css/styles.css",
36
36
  "exports": {
37
37
  ".": {
38
- "require": "./lib/index.js",
39
38
  "import": "./es/index.js"
40
39
  },
41
40
  "./assets/css/styles": "./assets/css/styles.css",
@@ -62,15 +61,15 @@
62
61
  "dependencies": {
63
62
  "@babel/runtime": "^7.13.10",
64
63
  "@folklore/size": "^0.1.20",
65
- "@micromag/core": "^0.3.541",
66
- "@micromag/element-background": "^0.3.541",
67
- "@micromag/element-closed-captions": "^0.3.541",
68
- "@micromag/element-container": "^0.3.541",
69
- "@micromag/element-footer": "^0.3.541",
70
- "@micromag/element-header": "^0.3.541",
71
- "@micromag/element-image": "^0.3.541",
72
- "@micromag/element-video": "^0.3.541",
73
- "@micromag/transforms": "^0.3.541",
64
+ "@micromag/core": "^0.3.569",
65
+ "@micromag/element-background": "^0.3.569",
66
+ "@micromag/element-closed-captions": "^0.3.569",
67
+ "@micromag/element-container": "^0.3.569",
68
+ "@micromag/element-footer": "^0.3.569",
69
+ "@micromag/element-header": "^0.3.569",
70
+ "@micromag/element-image": "^0.3.569",
71
+ "@micromag/element-video": "^0.3.569",
72
+ "@micromag/transforms": "^0.3.569",
74
73
  "classnames": "^2.2.6",
75
74
  "lodash": "^4.17.21",
76
75
  "prop-types": "^15.7.2",
@@ -82,5 +81,5 @@
82
81
  "access": "public",
83
82
  "registry": "https://registry.npmjs.org/"
84
83
  },
85
- "gitHead": "6c04a7e327b5fbc096785c11320b3fbd3c5751c8"
84
+ "gitHead": "ceb71f23a32ab8df4a1563a1e5cd5598e539de4d"
86
85
  }
package/lib/index.js DELETED
@@ -1,727 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactIntl = require('react-intl');
6
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
8
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
9
- var size = require('@folklore/size');
10
- var classNames = require('classnames');
11
- var PropTypes = require('prop-types');
12
- var React = require('react');
13
- var core = require('@micromag/core');
14
- var components = require('@micromag/core/components');
15
- var contexts = require('@micromag/core/contexts');
16
- var hooks = require('@micromag/core/hooks');
17
- var utils = require('@micromag/core/utils');
18
- var Background = require('@micromag/element-background');
19
- var ClosedCaptions = require('@micromag/element-closed-captions');
20
- var Container = require('@micromag/element-container');
21
- var Footer = require('@micromag/element-footer');
22
- var Header = require('@micromag/element-header');
23
- var Image = require('@micromag/element-image');
24
- var Video = require('@micromag/element-video');
25
-
26
- /**
27
- * Locale loader
28
- */
29
- var packageCache = null;
30
- var useThree = function useThree() {
31
- // transport
32
- var _useState = React.useState({
33
- "package": packageCache
34
- }),
35
- _useState2 = _slicedToArray(_useState, 2),
36
- loadedPackage = _useState2[0]["package"],
37
- setLoadedPackage = _useState2[1];
38
- React.useEffect(function () {
39
- var canceled = false;
40
- if (loadedPackage !== null) {
41
- return function () {
42
- canceled = true;
43
- };
44
- }
45
- import('three').then(function (_ref) {
46
- var Scene = _ref.Scene,
47
- PerspectiveCamera = _ref.PerspectiveCamera,
48
- SphereBufferGeometry = _ref.SphereBufferGeometry,
49
- VideoTexture = _ref.VideoTexture,
50
- MeshBasicMaterial = _ref.MeshBasicMaterial,
51
- Mesh = _ref.Mesh,
52
- WebGLRenderer = _ref.WebGLRenderer,
53
- MathUtils = _ref.MathUtils;
54
- packageCache = {
55
- Scene: Scene,
56
- PerspectiveCamera: PerspectiveCamera,
57
- SphereBufferGeometry: SphereBufferGeometry,
58
- VideoTexture: VideoTexture,
59
- MeshBasicMaterial: MeshBasicMaterial,
60
- Mesh: Mesh,
61
- WebGLRenderer: WebGLRenderer,
62
- MathUtils: MathUtils
63
- };
64
- if (!canceled) {
65
- setLoadedPackage({
66
- "package": packageCache
67
- });
68
- }
69
- });
70
- return function () {
71
- canceled = true;
72
- };
73
- }, [loadedPackage, setLoadedPackage]);
74
- return loadedPackage;
75
- };
76
-
77
- var styles = {"container":"micromag-screen-video-360-container","canvasButton":"micromag-screen-video-360-canvasButton","placeholder":"micromag-screen-video-360-placeholder","inner":"micromag-screen-video-360-inner","canvas":"micromag-screen-video-360-canvas","video":"micromag-screen-video-360-video","background":"micromag-screen-video-360-background","disabled":"micromag-screen-video-360-disabled","hidden":"micromag-screen-video-360-hidden","content":"micromag-screen-video-360-content","empty":"micromag-screen-video-360-empty","videoContainer":"micromag-screen-video-360-videoContainer","mediaControls":"micromag-screen-video-360-mediaControls","header":"micromag-screen-video-360-header","bottom":"micromag-screen-video-360-bottom","showVideo":"micromag-screen-video-360-showVideo"};
78
-
79
- var propTypes = {
80
- layout: PropTypes.oneOf(['full']),
81
- video: core.PropTypes.videoElement,
82
- header: core.PropTypes.header,
83
- footer: core.PropTypes.footer,
84
- background: core.PropTypes.backgroundElement,
85
- current: PropTypes.bool,
86
- active: PropTypes.bool,
87
- type: PropTypes.string,
88
- spacing: PropTypes.number,
89
- mediaRef: PropTypes.func,
90
- className: PropTypes.string
91
- };
92
- var defaultProps = {
93
- layout: 'full',
94
- video: null,
95
- header: null,
96
- footer: null,
97
- background: null,
98
- current: true,
99
- active: true,
100
- type: null,
101
- spacing: 20,
102
- mediaRef: null,
103
- className: null
104
- };
105
- var Video360Screen = function Video360Screen(_ref) {
106
- _ref.layout;
107
- var video = _ref.video,
108
- header = _ref.header,
109
- footer = _ref.footer,
110
- background = _ref.background,
111
- current = _ref.current,
112
- active = _ref.active,
113
- type = _ref.type,
114
- spacing = _ref.spacing,
115
- customMediaRef = _ref.mediaRef,
116
- className = _ref.className;
117
- var THREE = useThree();
118
- var trackScreenEvent = hooks.useTrackScreenEvent(type);
119
- var trackScreenMedia = hooks.useTrackScreenMedia('video_360');
120
- var _useViewerInteraction = contexts.useViewerInteraction(),
121
- enableInteraction = _useViewerInteraction.enableInteraction,
122
- disableInteraction = _useViewerInteraction.disableInteraction;
123
- var _useViewerNavigation = contexts.useViewerNavigation(),
124
- gotoPreviousScreen = _useViewerNavigation.gotoPreviousScreen,
125
- gotoNextScreen = _useViewerNavigation.gotoNextScreen;
126
- var _useViewerContext = contexts.useViewerContext(),
127
- viewerTopHeight = _useViewerContext.topHeight,
128
- viewerBottomHeight = _useViewerContext.bottomHeight,
129
- viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
130
- var _useScreenSize = contexts.useScreenSize(),
131
- width = _useScreenSize.width,
132
- height = _useScreenSize.height,
133
- landscape = _useScreenSize.landscape,
134
- resolution = _useScreenSize.resolution;
135
- var _useScreenRenderConte = contexts.useScreenRenderContext(),
136
- isView = _useScreenRenderConte.isView,
137
- isPreview = _useScreenRenderConte.isPreview,
138
- isPlaceholder = _useScreenRenderConte.isPlaceholder,
139
- isEdit = _useScreenRenderConte.isEdit,
140
- isStatic = _useScreenRenderConte.isStatic,
141
- isCapture = _useScreenRenderConte.isCapture;
142
- var _useViewerWebView = contexts.useViewerWebView(),
143
- openWebView = _useViewerWebView.open;
144
- var backgroundPlaying = current && (isView || isEdit);
145
- var mediaShouldLoad = current || active;
146
- var _ref2 = video || {},
147
- _ref2$media = _ref2.media,
148
- videoMedia = _ref2$media === void 0 ? null : _ref2$media,
149
- _ref2$closedCaptions = _ref2.closedCaptions,
150
- closedCaptions = _ref2$closedCaptions === void 0 ? null : _ref2$closedCaptions,
151
- _ref2$captions = _ref2.captions,
152
- captions = _ref2$captions === void 0 ? null : _ref2$captions,
153
- _ref2$withSeekBar = _ref2.withSeekBar,
154
- withSeekBar = _ref2$withSeekBar === void 0 ? false : _ref2$withSeekBar,
155
- _ref2$withControls = _ref2.withControls,
156
- withControls = _ref2$withControls === void 0 ? false : _ref2$withControls,
157
- _ref2$autoPlay = _ref2.autoPlay,
158
- autoPlay = _ref2$autoPlay === void 0 ? true : _ref2$autoPlay,
159
- _ref2$color = _ref2.color,
160
- color = _ref2$color === void 0 ? null : _ref2$color,
161
- _ref2$progressColor = _ref2.progressColor,
162
- progressColor = _ref2$progressColor === void 0 ? null : _ref2$progressColor;
163
- var videoContainerRef = React.useRef();
164
- var _usePlaybackContext = contexts.usePlaybackContext(),
165
- playing = _usePlaybackContext.playing,
166
- muted = _usePlaybackContext.muted,
167
- setControls = _usePlaybackContext.setControls,
168
- setControlsTheme = _usePlaybackContext.setControlsTheme,
169
- setControlsSuggestPlay = _usePlaybackContext.setControlsSuggestPlay,
170
- setMedia = _usePlaybackContext.setMedia,
171
- setPlaying = _usePlaybackContext.setPlaying,
172
- showControls = _usePlaybackContext.showControls,
173
- hideControls = _usePlaybackContext.hideControls;
174
- var mediaRef = React.useRef(null);
175
- React.useEffect(function () {
176
- if (!current) {
177
- return function () {};
178
- }
179
- if (withControls || withSeekBar) {
180
- setControls(true);
181
- setControlsTheme({
182
- seekBarOnly: withSeekBar && !withControls,
183
- color: color,
184
- progressColor: progressColor
185
- });
186
- } else {
187
- setControls(false);
188
- }
189
- return function () {
190
- if (withControls || withSeekBar) {
191
- setControls(false);
192
- }
193
- };
194
- }, [current, withControls, setControls, withSeekBar, color, progressColor]);
195
- React.useEffect(function () {
196
- if (!current) {
197
- return function () {};
198
- }
199
- setMedia(mediaRef.current);
200
- return function () {
201
- setMedia(null);
202
- };
203
- }, [current]);
204
- React.useEffect(function () {
205
- if (customMediaRef !== null) {
206
- customMediaRef(mediaRef.current);
207
- }
208
- }, [mediaRef.current]);
209
- React.useEffect(function () {
210
- if (current && autoPlay && !playing) {
211
- setPlaying(true);
212
- }
213
- }, [current, autoPlay]);
214
- var viewerContainer = contexts.useViewerContainer();
215
- var _useActivityDetector = hooks.useActivityDetector({
216
- element: viewerContainer,
217
- disabled: !isView,
218
- timeout: 2000
219
- }),
220
- activityDetected = _useActivityDetector.detected;
221
- var toggleControlsVisibility = React.useCallback(function () {
222
- if (activityDetected) {
223
- showControls();
224
- } else {
225
- hideControls();
226
- }
227
- }, [activityDetected, showControls, hideControls]);
228
- hooks.useDebounce(toggleControlsVisibility, activityDetected, 1000);
229
- var _useState = React.useState(null),
230
- _useState2 = _slicedToArray(_useState, 2),
231
- currentTime = _useState2[0],
232
- setCurrentTime = _useState2[1];
233
- var _useState3 = React.useState(null),
234
- _useState4 = _slicedToArray(_useState3, 2),
235
- duration = _useState4[0],
236
- setDuration = _useState4[1];
237
- var onTimeUpdate = React.useCallback(function (time) {
238
- setCurrentTime(time);
239
- }, [setDuration, duration]);
240
- var onProgressStep = React.useCallback(function (step) {
241
- trackScreenMedia(video, "progress_".concat(Math.round(step * 100, 10), "%"));
242
- }, [trackScreenMedia, video]);
243
- var onDurationChange = React.useCallback(function (dur) {
244
- setDuration(dur);
245
- }, [setDuration]);
246
- var onPlay = React.useCallback(function (_ref3) {
247
- var initial = _ref3.initial;
248
- trackScreenMedia(video, initial ? 'play' : 'resume');
249
- }, [trackScreenMedia, video]);
250
- var onPause = React.useCallback(function (_ref4) {
251
- var midway = _ref4.midway;
252
- trackScreenMedia(video, midway ? 'pause' : 'ended');
253
- }, [trackScreenMedia, video]);
254
- var onSeeked = React.useCallback(function (time) {
255
- if (time > 0) {
256
- trackScreenMedia(video, 'seek');
257
- }
258
- }, [trackScreenMedia, video]);
259
- var onEnded = React.useCallback(function () {
260
- if (current) {
261
- setPlaying(false);
262
- }
263
- }, [current, setPlaying]);
264
-
265
- // ------------------------------------
266
-
267
- var hasVideo = video !== null;
268
- var _useState5 = React.useState(!hasVideo),
269
- _useState6 = _slicedToArray(_useState5, 2),
270
- ready = _useState6[0],
271
- setReady = _useState6[1];
272
-
273
- // const transitionPlaying = current && ready;
274
- // const transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
275
-
276
- var hasHeader = utils.isHeaderFilled(header);
277
- var hasFooter = utils.isFooterFilled(footer);
278
- var footerProps = utils.getFooterProps(footer, {
279
- isView: isView,
280
- current: current,
281
- openWebView: openWebView,
282
- isPreview: isPreview,
283
- enableInteraction: enableInteraction,
284
- disableInteraction: disableInteraction
285
- });
286
- var finalVideo = hasVideo ? _objectSpread(_objectSpread({}, video), {}, {
287
- autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
288
- }) : null;
289
- var _ref5 = videoMedia || {},
290
- _ref5$metadata = _ref5.metadata,
291
- videoMetadata = _ref5$metadata === void 0 ? null : _ref5$metadata,
292
- _ref5$url = _ref5.url,
293
- videoUrl = _ref5$url === void 0 ? null : _ref5$url,
294
- _ref5$thumbnail_url = _ref5.thumbnail_url,
295
- thumbnailUrl = _ref5$thumbnail_url === void 0 ? null : _ref5$thumbnail_url;
296
- var hasVideoUrl = videoUrl !== null;
297
- var _ref6 = videoMetadata || {},
298
- _ref6$width = _ref6.width,
299
- videoWidth = _ref6$width === void 0 ? 0 : _ref6$width,
300
- _ref6$height = _ref6.height,
301
- videoHeight = _ref6$height === void 0 ? 0 : _ref6$height;
302
- var hasThumbnail = thumbnailUrl !== null;
303
- var _useState7 = React.useState(!hasThumbnail),
304
- _useState8 = _slicedToArray(_useState7, 2),
305
- posterReady = _useState8[0],
306
- setPosterReady = _useState8[1];
307
- var withVideoSphere = hasVideoUrl && (isView || isEdit) && !isCapture && !isStatic;
308
- var _getSizeWithinBounds = size.getSizeWithinBounds(videoWidth, videoHeight, width, height, {
309
- cover: true
310
- }),
311
- resizedVideoWidth = _getSizeWithinBounds.width,
312
- resizedVideoHeight = _getSizeWithinBounds.height;
313
- var resizedVideoLeft = -(resizedVideoWidth - width) / 2;
314
- var resizedVideoTop = -(resizedVideoHeight - height) / 2;
315
- React.useEffect(function () {
316
- setReady(!hasVideoUrl);
317
- }, [videoUrl, hasVideoUrl, setReady]);
318
- React.useEffect(function () {
319
- setPosterReady(!hasThumbnail);
320
- }, [thumbnailUrl, hasThumbnail, setPosterReady]);
321
- var onVideoReady = React.useCallback(function () {
322
- setReady(true);
323
- }, [setReady]);
324
- var onPosterLoaded = React.useCallback(function () {
325
- setPosterReady(true);
326
- }, [posterReady]);
327
-
328
- // 3D layer --------------------------
329
-
330
- var canvasRef = React.useRef(null);
331
- var camera = React.useRef(null);
332
- var scene = React.useRef(null);
333
- var renderer = React.useRef(null);
334
- var lon = React.useRef(0);
335
- var lat = React.useRef(0);
336
- var phi = React.useRef(0);
337
- var theta = React.useRef(0);
338
- var distance = React.useRef(50);
339
- var pointerDown = React.useRef(false);
340
- var pointerDownX = React.useRef(0);
341
- var pointerDownY = React.useRef(0);
342
- var pointerLon = React.useRef(0);
343
- var pointerLat = React.useRef(0);
344
-
345
- // render 3D frame
346
-
347
- var render3D = React.useCallback(function () {
348
- if (THREE === null) {
349
- return;
350
- }
351
- var MathUtils = THREE.MathUtils;
352
- lat.current = Math.max(-85, Math.min(85, lat.current));
353
- phi.current = MathUtils.degToRad(90 - lat.current);
354
- theta.current = MathUtils.degToRad(lon.current);
355
- camera.current.position.x = distance.current * Math.sin(phi.current) * Math.cos(theta.current);
356
- camera.current.position.y = distance.current * Math.cos(phi.current);
357
- camera.current.position.z = distance.current * Math.sin(phi.current) * Math.sin(theta.current);
358
- camera.current.lookAt(0, 0, 0);
359
- renderer.current.render(scene.current, camera.current);
360
- }, []);
361
-
362
- // Init 3D layer
363
-
364
- React.useEffect(function () {
365
- if (THREE !== null && hasVideoUrl && withVideoSphere) {
366
- var Scene = THREE.Scene,
367
- PerspectiveCamera = THREE.PerspectiveCamera,
368
- SphereBufferGeometry = THREE.SphereBufferGeometry,
369
- VideoTexture = THREE.VideoTexture,
370
- MeshBasicMaterial = THREE.MeshBasicMaterial,
371
- Mesh = THREE.Mesh,
372
- WebGLRenderer = THREE.WebGLRenderer;
373
- var _canvasRef$current = canvasRef.current,
374
- canvasWidth = _canvasRef$current.offsetWidth,
375
- canvasHeight = _canvasRef$current.offsetHeight;
376
- camera.current = new PerspectiveCamera(75, canvasWidth / canvasHeight, 1, 1100);
377
- scene.current = new Scene();
378
- var geometry = new SphereBufferGeometry(500, 60, 40);
379
- geometry.scale(-1, 1, 1);
380
- var _ref7 = mediaRef || {},
381
- _ref7$current = _ref7.current,
382
- videoElement = _ref7$current === void 0 ? null : _ref7$current;
383
- var videoTexture = new VideoTexture(videoElement);
384
- var videoMaterial = new MeshBasicMaterial({
385
- map: videoTexture
386
- });
387
- var mesh = new Mesh(geometry, videoMaterial);
388
- scene.current.add(mesh);
389
- renderer.current = new WebGLRenderer({
390
- canvas: canvasRef.current
391
- });
392
- renderer.current.setPixelRatio(typeof window !== 'undefined' ? window.devicePixelRatio : 1);
393
- renderer.current.setSize(canvasWidth, canvasHeight);
394
- render3D();
395
- }
396
- return function () {
397
- if (withVideoSphere) {
398
- camera.current = null;
399
- scene.current = null;
400
- renderer.current = null;
401
- }
402
- };
403
- }, [hasVideoUrl, withVideoSphere, render3D]);
404
- hooks.useAnimationFrame(render3D, {
405
- disabled: !withVideoSphere
406
- });
407
-
408
- // Resize 3D layer
409
-
410
- React.useEffect(function () {
411
- if (camera.current !== null && renderer.current !== null) {
412
- camera.current.aspect = width / height;
413
- camera.current.updateProjectionMatrix();
414
- renderer.current.setSize(width, height);
415
- }
416
- }, [width, height]);
417
-
418
- // Pointer interaction
419
- var togglePlayTimeout = React.useRef(null);
420
- var onPointerDown = React.useCallback(function (e) {
421
- pointerDown.current = true;
422
- pointerDownX.current = e.clientX;
423
- pointerDownY.current = e.clientY;
424
- pointerLon.current = lon.current;
425
- pointerLat.current = lat.current;
426
- // if (togglePlayTimeout.current !== null) {
427
- // clearTimeout(togglePlayTimeout.current);
428
- // }
429
- // togglePlayTimeout.current = setTimeout(() => {
430
- // togglePlay();
431
- // togglePlayTimeout.current = null;
432
- // }, 300);
433
- }, [
434
- /* togglePlay */
435
- ]);
436
- var pixelsMoved = React.useRef(0);
437
- var lastPointerClient = React.useRef(null);
438
- var pixelsMovedTracked = React.useRef(false);
439
- var onPointerMove = React.useCallback(function (e) {
440
- if (pointerDown.current) {
441
- var _ref8 = e || {},
442
- _ref8$clientX = _ref8.clientX,
443
- clientX = _ref8$clientX === void 0 ? null : _ref8$clientX,
444
- _ref8$clientY = _ref8.clientY,
445
- clientY = _ref8$clientY === void 0 ? null : _ref8$clientY;
446
- var downDeltaX = pointerDownX.current - clientX;
447
- var downDeltaY = pointerDownY.current - clientY;
448
- lon.current = downDeltaX * 0.2 + pointerLon.current;
449
- lat.current = downDeltaY * 0.2 + pointerLat.current;
450
- var _ref9 = lastPointerClient.current || {},
451
- _ref9$x = _ref9.x,
452
- lastX = _ref9$x === void 0 ? clientX : _ref9$x,
453
- _ref9$y = _ref9.y,
454
- lastY = _ref9$y === void 0 ? clientY : _ref9$y;
455
- var deltaX = Math.abs(lastX - clientX) || 0;
456
- var deltaY = Math.abs(lastY - clientY) || 0;
457
- pixelsMoved.current += deltaX + deltaY;
458
- if (!pixelsMovedTracked.current && pixelsMoved.current > Math.min(width, height)) {
459
- trackScreenEvent('drag_sphere', video.name);
460
- pixelsMovedTracked.current = true;
461
- }
462
- lastPointerClient.current = {
463
- x: clientX,
464
- y: clientY
465
- };
466
- if (Math.abs(downDeltaX) > 3 || Math.abs(downDeltaY) > 3) {
467
- if (togglePlayTimeout.current !== null) {
468
- clearTimeout(togglePlayTimeout.current);
469
- togglePlayTimeout.current = null;
470
- }
471
- }
472
- }
473
- }, [width, height, trackScreenEvent, video]);
474
- var onPointerUp = React.useCallback(function (e) {
475
- var videoContainer = videoContainerRef.current;
476
- if (pointerDown.current && videoContainer !== null) {
477
- var distX = Math.abs(pointerDownX.current - e.clientX);
478
- var distY = Math.abs(pointerDownY.current - e.clientY);
479
- var pixelsMovedTolerance = 3;
480
- var tapNextScreenWidthPercent = 0.5;
481
- var canTapToNavigate = !landscape && togglePlayTimeout.current !== null;
482
- var validNavigateTap = canTapToNavigate && distX < pixelsMovedTolerance && distY < pixelsMovedTolerance;
483
- if (validNavigateTap) {
484
- var _videoContainer$getBo = videoContainer.getBoundingClientRect(),
485
- _videoContainer$getBo2 = _videoContainer$getBo.left,
486
- containerX = _videoContainer$getBo2 === void 0 ? 0 : _videoContainer$getBo2,
487
- containerWidth = _videoContainer$getBo.width;
488
- var hasTappedLeft = e.clientX - containerX < containerWidth * (1 - tapNextScreenWidthPercent);
489
- if (hasTappedLeft) {
490
- if (gotoPreviousScreen !== null) {
491
- gotoPreviousScreen();
492
- }
493
- } else if (gotoNextScreen !== null) {
494
- gotoNextScreen();
495
- }
496
- }
497
- if (togglePlayTimeout.current !== null) {
498
- clearTimeout(togglePlayTimeout.current);
499
- togglePlayTimeout.current = null;
500
- }
501
- }
502
- pointerDown.current = false;
503
- }, [gotoPreviousScreen, gotoNextScreen, landscape]);
504
- var onPlayError = React.useCallback(function () {
505
- if (isView && playing && current && hasVideoUrl && autoPlay) {
506
- setPlaying(false);
507
- setControlsSuggestPlay(true);
508
- }
509
- }, [isView, current, playing, hasVideoUrl, autoPlay, setPlaying, setControlsSuggestPlay]);
510
- return /*#__PURE__*/React.createElement("div", {
511
- className: classNames([styles.container, _defineProperty(_defineProperty({}, className, className !== null), styles.showVideo, isPreview || isStatic || isCapture)]),
512
- "data-screen-ready": (isStatic || isCapture) && posterReady || ready
513
- }, /*#__PURE__*/React.createElement(Container, {
514
- width: width,
515
- height: height,
516
- className: styles.content
517
- }, withVideoSphere ? /*#__PURE__*/React.createElement("div", {
518
- ref: videoContainerRef,
519
- className: styles.videoContainer,
520
- style: {
521
- width: resizedVideoWidth,
522
- height: resizedVideoHeight,
523
- left: resizedVideoLeft,
524
- top: resizedVideoTop
525
- }
526
- }, /*#__PURE__*/React.createElement(Video, Object.assign({}, finalVideo, {
527
- mediaRef: mediaRef,
528
- className: styles.video,
529
- paused: !current || !playing,
530
- muted: muted,
531
- withoutCors: true,
532
- onReady: onVideoReady,
533
- onPlay: onPlay,
534
- onPause: onPause,
535
- onTimeUpdate: onTimeUpdate,
536
- onProgressStep: onProgressStep,
537
- onDurationChange: onDurationChange,
538
- onSeeked: onSeeked,
539
- onEnded: onEnded,
540
- onPosterLoaded: onPosterLoaded,
541
- onPlayError: onPlayError,
542
- setPlaying: setPlaying,
543
- focusable: current && isView,
544
- shouldLoad: mediaShouldLoad
545
- }))) : null, /*#__PURE__*/React.createElement("div", {
546
- className: styles.inner
547
- }, /*#__PURE__*/React.createElement(components.ScreenElement, {
548
- key: "video",
549
- placeholder: /*#__PURE__*/React.createElement(components.PlaceholderVideo360, {
550
- className: styles.placeholder,
551
- width: "100%",
552
- height: "100%"
553
- }),
554
- emptyClassName: styles.empty,
555
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
556
- id: "oLtEu6",
557
- defaultMessage: [{
558
- "type": 0,
559
- "value": "Video 360"
560
- }]
561
- }),
562
- isEmpty: !withVideoSphere
563
- }, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
564
- key: "header",
565
- className: styles.header,
566
- style: {
567
- paddingTop: spacing / 2,
568
- paddingLeft: spacing,
569
- paddingRight: spacing,
570
- transform: !isPreview ? "translate(0, ".concat(viewerTopHeight, "px)") : null
571
- }
572
- }, /*#__PURE__*/React.createElement(Header, header)) : null, withVideoSphere ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("canvas", {
573
- ref: canvasRef,
574
- className: styles.canvas
575
- }), /*#__PURE__*/React.createElement("button", {
576
- className: styles.canvasButton,
577
- type: "button",
578
- "aria-label": "canvas-interaction",
579
- onPointerDown: onPointerDown,
580
- onPointerMove: onPointerMove,
581
- onPointerUp: onPointerUp,
582
- tabIndex: current && isView ? null : '-1'
583
- })) : /*#__PURE__*/React.createElement("div", {
584
- className: styles.videoContainer,
585
- style: {
586
- width: resizedVideoWidth,
587
- height: resizedVideoHeight,
588
- left: resizedVideoLeft,
589
- top: resizedVideoTop
590
- }
591
- }, /*#__PURE__*/React.createElement(Image, {
592
- className: styles.video,
593
- media: {
594
- url: thumbnailUrl,
595
- metadata: {
596
- width: videoWidth,
597
- height: videoHeight
598
- }
599
- },
600
- width: resizedVideoWidth,
601
- height: resizedVideoHeight,
602
- resolution: resolution
603
- }))), !isPlaceholder ? /*#__PURE__*/React.createElement("div", {
604
- key: "bottom-content",
605
- className: styles.bottom,
606
- style: {
607
- transform: current && !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
608
- paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
609
- paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
610
- paddingBottom: spacing / 2,
611
- paddingTop: 0
612
- }
613
- }, (closedCaptions !== null || captions !== null) && !isPreview && !isCapture && !isStatic ? /*#__PURE__*/React.createElement(ClosedCaptions, Object.assign({
614
- className: styles.closedCaptions,
615
- media: closedCaptions
616
- }, captions, {
617
- currentTime: currentTime
618
- })) : null, hasFooter ? /*#__PURE__*/React.createElement(Footer, Object.assign({}, footerProps, {
619
- className: styles.callToAction
620
- })) : null) : null)), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
621
- background: background,
622
- width: width,
623
- height: height,
624
- resolution: resolution,
625
- playing: backgroundPlaying,
626
- muted: muted,
627
- shouldLoad: mediaShouldLoad,
628
- withoutVideo: isPreview,
629
- className: styles.background
630
- }) : null);
631
- };
632
- Video360Screen.propTypes = propTypes;
633
- Video360Screen.defaultProps = defaultProps;
634
- var Video360Screen$1 = Video360Screen;
635
-
636
- // import * as transforms from './transforms/index';
637
-
638
- var definition = {
639
- id: 'video-360',
640
- type: 'screen',
641
- group: {
642
- label: reactIntl.defineMessage({
643
- id: "+9akmg",
644
- defaultMessage: [{
645
- "type": 0,
646
- "value": "Audio and Video"
647
- }]
648
- }),
649
- order: 5
650
- },
651
- title: reactIntl.defineMessage({
652
- id: "GRVidW",
653
- defaultMessage: [{
654
- "type": 0,
655
- "value": "360 Video"
656
- }]
657
- }),
658
- component: Video360Screen$1,
659
- layouts: ['full'],
660
- // transforms,
661
- fields: [{
662
- name: 'video',
663
- type: 'video-element',
664
- theme: {
665
- color: 'primary'
666
- },
667
- defaultValue: {
668
- autoPlay: true
669
- },
670
- label: reactIntl.defineMessage({
671
- id: "tvl2Zc",
672
- defaultMessage: [{
673
- "type": 0,
674
- "value": "Video"
675
- }]
676
- })
677
- }, {
678
- name: 'background',
679
- type: 'background',
680
- label: reactIntl.defineMessage({
681
- id: "+MPZRu",
682
- defaultMessage: [{
683
- "type": 0,
684
- "value": "Background"
685
- }]
686
- })
687
- }, {
688
- name: 'header',
689
- type: 'header',
690
- label: reactIntl.defineMessage({
691
- id: "rhuDxI",
692
- defaultMessage: [{
693
- "type": 0,
694
- "value": "Header"
695
- }]
696
- }),
697
- theme: {
698
- badge: {
699
- label: {
700
- textStyle: 'badge'
701
- },
702
- boxStyle: 'badge'
703
- }
704
- }
705
- }, {
706
- name: 'footer',
707
- type: 'footer',
708
- label: reactIntl.defineMessage({
709
- id: "g4nybp",
710
- defaultMessage: [{
711
- "type": 0,
712
- "value": "Footer"
713
- }]
714
- }),
715
- theme: {
716
- callToAction: {
717
- label: {
718
- textStyle: 'cta'
719
- },
720
- boxStyle: 'cta'
721
- }
722
- }
723
- }]
724
- };
725
-
726
- exports.Video360Screen = Video360Screen$1;
727
- exports.default = definition;