@micromag/screen-video-360 0.3.147 → 0.3.152
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/assets/css/styles.css +1 -1
- package/es/index.js +174 -135
- package/lib/index.js +172 -134
- package/package.json +11 -11
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.micromag-screen-video-360-container .micromag-screen-video-360-canvasButton{display:inline-block;position:relative;padding:0;border:0;background:rgba(0,0,0,0);color:inherit;font-family:inherit;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.micromag-screen-video-360-container .micromag-screen-video-360-canvas,.micromag-screen-video-360-container .micromag-screen-video-360-canvasButton,.micromag-screen-video-360-container .micromag-screen-video-360-content,.micromag-screen-video-360-container .micromag-screen-video-360-placeholder,.micromag-screen-video-360-container .micromag-screen-video-360-video{position:absolute;top:0;left:0;width:100%;height:100%}.micromag-screen-video-360-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-video-360-disabled.micromag-screen-video-360-container{overflow:hidden;pointer-events:none}.micromag-screen-video-360-hidden.micromag-screen-video-360-container{display:none;visibility:hidden}.micromag-screen-video-360-placeholder.micromag-screen-video-360-container .micromag-screen-video-360-content{position:relative;padding:6px}.micromag-screen-video-360-container .micromag-screen-video-360-empty{margin:5px auto;border:2px dashed #343434;color:#343434;height:100%;margin:0}.micromag-screen-video-360-container .micromag-screen-video-360-canvasButton{-ms-touch-action:none;touch-action:none}.micromag-screen-video-360-container .micromag-screen-video-360-videoContainer{position:absolute}.micromag-screen-video-360-container .micromag-screen-video-360-video{visibility:hidden}.micromag-screen-video-360-container .micromag-screen-video-360-video video{height:100%}.micromag-screen-video-360-container .micromag-screen-video-360-mediaControls{padding:10px 20px 20px}.micromag-screen-video-360-container .micromag-screen-video-360-placeholder{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;height:100%}.micromag-screen-video-360-container .micromag-screen-video-360-
|
|
1
|
+
.micromag-screen-video-360-container .micromag-screen-video-360-canvasButton{display:inline-block;position:relative;padding:0;border:0;background:rgba(0,0,0,0);color:inherit;font-family:inherit;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.micromag-screen-video-360-container .micromag-screen-video-360-canvas,.micromag-screen-video-360-container .micromag-screen-video-360-canvasButton,.micromag-screen-video-360-container .micromag-screen-video-360-content,.micromag-screen-video-360-container .micromag-screen-video-360-placeholder,.micromag-screen-video-360-container .micromag-screen-video-360-video{position:absolute;top:0;left:0;width:100%;height:100%}.micromag-screen-video-360-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-video-360-disabled.micromag-screen-video-360-container{overflow:hidden;pointer-events:none}.micromag-screen-video-360-hidden.micromag-screen-video-360-container{display:none;visibility:hidden}.micromag-screen-video-360-placeholder.micromag-screen-video-360-container .micromag-screen-video-360-content{position:relative;padding:6px}.micromag-screen-video-360-container .micromag-screen-video-360-empty{margin:5px auto;border:2px dashed #343434;color:#343434;height:100%;margin:0}.micromag-screen-video-360-container .micromag-screen-video-360-canvasButton{-ms-touch-action:none;touch-action:none}.micromag-screen-video-360-container .micromag-screen-video-360-videoContainer{position:absolute}.micromag-screen-video-360-container .micromag-screen-video-360-video{visibility:hidden}.micromag-screen-video-360-container .micromag-screen-video-360-video video{height:100%}.micromag-screen-video-360-container .micromag-screen-video-360-mediaControls{padding:10px 20px 20px}.micromag-screen-video-360-container .micromag-screen-video-360-placeholder{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;height:100%}.micromag-screen-video-360-container .micromag-screen-video-360-bottom{position:absolute;bottom:0;left:0;width:100%;-webkit-transition:padding .2s ease-out,-webkit-transform .2s ease-out;transition:padding .2s ease-out,-webkit-transform .2s ease-out;-o-transition:transform .2s ease-out,padding .2s ease-out;transition:transform .2s ease-out,padding .2s ease-out;transition:transform .2s ease-out,padding .2s ease-out,-webkit-transform .2s ease-out}.micromag-screen-video-360-container .micromag-screen-video-360-bottom>*{margin-bottom:10px}.micromag-screen-video-360-container .micromag-screen-video-360-bottom>:last-child{margin-bottom:0}.micromag-screen-video-360-container.micromag-screen-video-360-showVideo .micromag-screen-video-360-video{visibility:visible}
|
package/es/index.js
CHANGED
|
@@ -9,20 +9,17 @@ import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
|
9
9
|
import 'whatwg-fetch';
|
|
10
10
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
11
11
|
import { ScreenElement, PlaceholderVideo360, Transitions } from '@micromag/core/components';
|
|
12
|
-
import { useScreenSize, useScreenRenderContext } from '@micromag/core/contexts';
|
|
13
|
-
import { useTrackScreenEvent, useTrackScreenMedia, useAnimationFrame } from '@micromag/core/hooks';
|
|
12
|
+
import { useViewerInteraction, useViewerNavigation, useViewerContext, useScreenSize, useScreenRenderContext, useViewerWebView, usePlaybackContext } from '@micromag/core/contexts';
|
|
13
|
+
import { useTrackScreenEvent, useTrackScreenMedia, useActivityDetector, useAnimationFrame } from '@micromag/core/hooks';
|
|
14
14
|
import Background from '@micromag/element-background';
|
|
15
15
|
import CallToAction from '@micromag/element-call-to-action';
|
|
16
16
|
import ClosedCaptions from '@micromag/element-closed-captions';
|
|
17
17
|
import Container from '@micromag/element-container';
|
|
18
18
|
import Image from '@micromag/element-image';
|
|
19
|
-
import MediaControls from '@micromag/element-media-controls';
|
|
20
19
|
import Video from '@micromag/element-video';
|
|
21
20
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
22
21
|
import { Video as Video$1, Container as Container$1 } from '@micromag/transforms/apple-news';
|
|
23
22
|
|
|
24
|
-
var styles = {"container":"micromag-screen-video-360-container","canvasButton":"micromag-screen-video-360-canvasButton","canvas":"micromag-screen-video-360-canvas","content":"micromag-screen-video-360-content","placeholder":"micromag-screen-video-360-placeholder","video":"micromag-screen-video-360-video","disabled":"micromag-screen-video-360-disabled","hidden":"micromag-screen-video-360-hidden","empty":"micromag-screen-video-360-empty","videoContainer":"micromag-screen-video-360-videoContainer","mediaControls":"micromag-screen-video-360-mediaControls","bottomContent":"micromag-screen-video-360-bottomContent","showVideo":"micromag-screen-video-360-showVideo"};
|
|
25
|
-
|
|
26
23
|
/**
|
|
27
24
|
* Locale loader
|
|
28
25
|
*/
|
|
@@ -80,6 +77,8 @@ var useThree = function useThree() {
|
|
|
80
77
|
return loadedPackage;
|
|
81
78
|
};
|
|
82
79
|
|
|
80
|
+
var styles = {"container":"micromag-screen-video-360-container","canvasButton":"micromag-screen-video-360-canvasButton","canvas":"micromag-screen-video-360-canvas","content":"micromag-screen-video-360-content","placeholder":"micromag-screen-video-360-placeholder","video":"micromag-screen-video-360-video","disabled":"micromag-screen-video-360-disabled","hidden":"micromag-screen-video-360-hidden","empty":"micromag-screen-video-360-empty","videoContainer":"micromag-screen-video-360-videoContainer","mediaControls":"micromag-screen-video-360-mediaControls","bottom":"micromag-screen-video-360-bottom","showVideo":"micromag-screen-video-360-showVideo"};
|
|
81
|
+
|
|
83
82
|
var propTypes = {
|
|
84
83
|
layout: PropTypes.oneOf(['full']),
|
|
85
84
|
video: PropTypes$1.videoElement,
|
|
@@ -88,12 +87,9 @@ var propTypes = {
|
|
|
88
87
|
current: PropTypes.bool,
|
|
89
88
|
active: PropTypes.bool,
|
|
90
89
|
transitions: PropTypes$1.transitions,
|
|
91
|
-
onPrevious: PropTypes.func,
|
|
92
|
-
onNext: PropTypes.func,
|
|
93
90
|
type: PropTypes.string,
|
|
94
91
|
spacing: PropTypes.number,
|
|
95
|
-
|
|
96
|
-
disableInteraction: PropTypes.func,
|
|
92
|
+
mediaRef: PropTypes.func,
|
|
97
93
|
className: PropTypes.string
|
|
98
94
|
};
|
|
99
95
|
var defaultProps = {
|
|
@@ -104,17 +100,14 @@ var defaultProps = {
|
|
|
104
100
|
current: true,
|
|
105
101
|
active: true,
|
|
106
102
|
transitions: null,
|
|
107
|
-
onPrevious: null,
|
|
108
|
-
onNext: null,
|
|
109
103
|
type: null,
|
|
110
104
|
spacing: 20,
|
|
111
|
-
|
|
112
|
-
disableInteraction: null,
|
|
105
|
+
mediaRef: null,
|
|
113
106
|
className: null
|
|
114
107
|
};
|
|
115
108
|
|
|
116
109
|
var Video360Screen = function Video360Screen(_ref) {
|
|
117
|
-
var
|
|
110
|
+
var _ref11;
|
|
118
111
|
|
|
119
112
|
_ref.layout;
|
|
120
113
|
var video = _ref.video,
|
|
@@ -123,17 +116,26 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
123
116
|
current = _ref.current,
|
|
124
117
|
active = _ref.active,
|
|
125
118
|
transitions = _ref.transitions,
|
|
126
|
-
onPrevious = _ref.onPrevious,
|
|
127
|
-
onNext = _ref.onNext,
|
|
128
119
|
type = _ref.type,
|
|
129
120
|
spacing = _ref.spacing,
|
|
130
|
-
|
|
131
|
-
disableInteraction = _ref.disableInteraction,
|
|
121
|
+
customMediaRef = _ref.mediaRef,
|
|
132
122
|
className = _ref.className;
|
|
133
123
|
var THREE = useThree();
|
|
134
124
|
var trackScreenEvent = useTrackScreenEvent(type);
|
|
135
125
|
var trackScreenMedia = useTrackScreenMedia('video_360');
|
|
136
126
|
|
|
127
|
+
var _useViewerInteraction = useViewerInteraction(),
|
|
128
|
+
enableInteraction = _useViewerInteraction.enableInteraction,
|
|
129
|
+
disableInteraction = _useViewerInteraction.disableInteraction;
|
|
130
|
+
|
|
131
|
+
var _useViewerNavigation = useViewerNavigation(),
|
|
132
|
+
gotoPreviousScreen = _useViewerNavigation.gotoPreviousScreen,
|
|
133
|
+
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
134
|
+
|
|
135
|
+
var _useViewerContext = useViewerContext(),
|
|
136
|
+
viewerBottomHeight = _useViewerContext.bottomHeight,
|
|
137
|
+
viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
|
|
138
|
+
|
|
137
139
|
var _useScreenSize = useScreenSize(),
|
|
138
140
|
width = _useScreenSize.width,
|
|
139
141
|
height = _useScreenSize.height,
|
|
@@ -148,17 +150,102 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
148
150
|
isStatic = _useScreenRenderConte.isStatic,
|
|
149
151
|
isCapture = _useScreenRenderConte.isCapture;
|
|
150
152
|
|
|
153
|
+
var _useViewerWebView = useViewerWebView(),
|
|
154
|
+
openWebView = _useViewerWebView.open;
|
|
155
|
+
|
|
151
156
|
var backgroundPlaying = current && (isView || isEdit);
|
|
152
157
|
var mediaShouldLoad = current || active;
|
|
158
|
+
|
|
159
|
+
var _ref2 = video || {},
|
|
160
|
+
_ref2$media = _ref2.media,
|
|
161
|
+
videoMedia = _ref2$media === void 0 ? null : _ref2$media,
|
|
162
|
+
_ref2$closedCaptions = _ref2.closedCaptions,
|
|
163
|
+
closedCaptions = _ref2$closedCaptions === void 0 ? null : _ref2$closedCaptions,
|
|
164
|
+
_ref2$withSeekBar = _ref2.withSeekBar,
|
|
165
|
+
withSeekBar = _ref2$withSeekBar === void 0 ? false : _ref2$withSeekBar,
|
|
166
|
+
_ref2$withControls = _ref2.withControls,
|
|
167
|
+
withControls = _ref2$withControls === void 0 ? false : _ref2$withControls,
|
|
168
|
+
_ref2$autoPlay = _ref2.autoPlay,
|
|
169
|
+
autoPlay = _ref2$autoPlay === void 0 ? true : _ref2$autoPlay,
|
|
170
|
+
_ref2$color = _ref2.color,
|
|
171
|
+
color = _ref2$color === void 0 ? null : _ref2$color,
|
|
172
|
+
_ref2$progressColor = _ref2.progressColor,
|
|
173
|
+
progressColor = _ref2$progressColor === void 0 ? null : _ref2$progressColor;
|
|
174
|
+
|
|
153
175
|
var videoContainerRef = useRef();
|
|
154
|
-
var apiRef = useRef();
|
|
155
176
|
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
177
|
+
var _usePlaybackContext = usePlaybackContext(),
|
|
178
|
+
playing = _usePlaybackContext.playing,
|
|
179
|
+
muted = _usePlaybackContext.muted,
|
|
180
|
+
setControls = _usePlaybackContext.setControls,
|
|
181
|
+
setControlsTheme = _usePlaybackContext.setControlsTheme,
|
|
182
|
+
setMedia = _usePlaybackContext.setMedia,
|
|
183
|
+
setPlaying = _usePlaybackContext.setPlaying,
|
|
184
|
+
showControls = _usePlaybackContext.showControls,
|
|
185
|
+
hideControls = _usePlaybackContext.hideControls;
|
|
186
|
+
|
|
187
|
+
var mediaRef = useRef(null);
|
|
188
|
+
useEffect(function () {
|
|
189
|
+
if (!current) {
|
|
190
|
+
return function () {};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (withControls || withSeekBar) {
|
|
194
|
+
setControls(true);
|
|
195
|
+
setControlsTheme({
|
|
196
|
+
seekBarOnly: withSeekBar && !withControls,
|
|
197
|
+
color: color,
|
|
198
|
+
progressColor: progressColor
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
setControls(false);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return function () {
|
|
205
|
+
if (withControls || withSeekBar) {
|
|
206
|
+
setControls(false);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}, [current, withControls, setControls, withSeekBar, color, progressColor]);
|
|
210
|
+
useEffect(function () {
|
|
211
|
+
if (!current) {
|
|
212
|
+
return function () {};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
setMedia(mediaRef.current);
|
|
216
|
+
return function () {
|
|
217
|
+
setMedia(null);
|
|
218
|
+
};
|
|
219
|
+
}, [current]);
|
|
220
|
+
useEffect(function () {
|
|
221
|
+
if (customMediaRef !== null) {
|
|
222
|
+
customMediaRef(mediaRef.current);
|
|
223
|
+
}
|
|
224
|
+
}, [mediaRef.current]);
|
|
225
|
+
useEffect(function () {
|
|
226
|
+
if (current && autoPlay && !playing) {
|
|
227
|
+
setPlaying(true);
|
|
228
|
+
}
|
|
229
|
+
}, [current, autoPlay]);
|
|
230
|
+
|
|
231
|
+
var _useActivityDetector = useActivityDetector({
|
|
232
|
+
disabled: !current || !isView,
|
|
233
|
+
timeout: 2000
|
|
234
|
+
}),
|
|
235
|
+
activityDetectorRef = _useActivityDetector.ref,
|
|
236
|
+
activityDetected = _useActivityDetector.detected;
|
|
237
|
+
|
|
238
|
+
useEffect(function () {
|
|
239
|
+
if (!current) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (activityDetected) {
|
|
244
|
+
showControls();
|
|
245
|
+
} else {
|
|
246
|
+
hideControls();
|
|
247
|
+
}
|
|
248
|
+
}, [activityDetected, showControls, hideControls]);
|
|
162
249
|
|
|
163
250
|
var _useState = useState(null),
|
|
164
251
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -170,78 +257,45 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
170
257
|
duration = _useState4[0],
|
|
171
258
|
setDuration = _useState4[1];
|
|
172
259
|
|
|
173
|
-
var _useState5 = useState(false),
|
|
174
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
175
|
-
playing = _useState6[0],
|
|
176
|
-
setPlaying = _useState6[1];
|
|
177
|
-
|
|
178
|
-
var _useState7 = useState(false),
|
|
179
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
180
|
-
muted = _useState8[0],
|
|
181
|
-
setMuted = _useState8[1];
|
|
182
|
-
|
|
183
260
|
var onTimeUpdate = useCallback(function (time) {
|
|
184
261
|
setCurrentTime(time);
|
|
185
262
|
}, [setDuration, duration]);
|
|
186
263
|
var onProgressStep = useCallback(function (step) {
|
|
187
264
|
trackScreenMedia(video, "progress_".concat(Math.round(step * 100, 10), "%"));
|
|
188
265
|
}, [trackScreenMedia, video]);
|
|
189
|
-
var
|
|
266
|
+
var onDurationChange = useCallback(function (dur) {
|
|
190
267
|
setDuration(dur);
|
|
191
268
|
}, [setDuration]);
|
|
192
269
|
var onPlay = useCallback(function (_ref3) {
|
|
193
270
|
var initial = _ref3.initial;
|
|
194
|
-
setPlaying(true);
|
|
195
271
|
trackScreenMedia(video, initial ? 'play' : 'resume');
|
|
196
272
|
}, [trackScreenMedia, video]);
|
|
197
273
|
var onPause = useCallback(function (_ref4) {
|
|
198
274
|
var midway = _ref4.midway;
|
|
199
|
-
setPlaying(false);
|
|
200
275
|
trackScreenMedia(video, midway ? 'pause' : 'ended');
|
|
201
276
|
}, [trackScreenMedia, video]);
|
|
202
|
-
var onVolumeChanged = useCallback(function (isMuted) {
|
|
203
|
-
setMuted(isMuted);
|
|
204
|
-
trackScreenMedia(video, isMuted ? 'mute' : 'unmute');
|
|
205
|
-
}, [trackScreenMedia, video]);
|
|
206
277
|
var onSeeked = useCallback(function (time) {
|
|
207
278
|
if (time > 0) {
|
|
208
279
|
trackScreenMedia(video, 'seek');
|
|
209
280
|
}
|
|
210
281
|
}, [trackScreenMedia, video]);
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
toggleMute();
|
|
217
|
-
}, [muted, toggleMute]);
|
|
218
|
-
useEffect(function () {
|
|
219
|
-
if (!current && playing) {
|
|
220
|
-
pause();
|
|
221
|
-
}
|
|
222
|
-
}, [playing, current]); // ------------------------------------
|
|
282
|
+
var onEnded = useCallback(function () {
|
|
283
|
+
setPlaying(false);
|
|
284
|
+
}, [setPlaying]); // ------------------------------------
|
|
223
285
|
|
|
224
286
|
var hasVideo = video !== null;
|
|
225
287
|
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
ready =
|
|
229
|
-
setReady =
|
|
288
|
+
var _useState5 = useState(!hasVideo),
|
|
289
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
290
|
+
ready = _useState6[0],
|
|
291
|
+
setReady = _useState6[1];
|
|
230
292
|
|
|
231
293
|
var transitionPlaying = current && ready;
|
|
232
294
|
var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
|
|
233
295
|
|
|
234
|
-
var _ref5 =
|
|
235
|
-
_ref5$
|
|
236
|
-
|
|
237
|
-
_ref5$closedCaptions = _ref5.closedCaptions,
|
|
238
|
-
closedCaptions = _ref5$closedCaptions === void 0 ? null : _ref5$closedCaptions,
|
|
239
|
-
_ref5$withSeekBar = _ref5.withSeekBar,
|
|
240
|
-
withSeekBar = _ref5$withSeekBar === void 0 ? false : _ref5$withSeekBar,
|
|
241
|
-
_ref5$withControls = _ref5.withControls,
|
|
242
|
-
withControls = _ref5$withControls === void 0 ? false : _ref5$withControls,
|
|
243
|
-
_ref5$autoPlay = _ref5.autoPlay,
|
|
244
|
-
autoPlay = _ref5$autoPlay === void 0 ? true : _ref5$autoPlay;
|
|
296
|
+
var _ref5 = callToAction || {},
|
|
297
|
+
_ref5$active = _ref5.active,
|
|
298
|
+
hasCallToAction = _ref5$active === void 0 ? false : _ref5$active;
|
|
245
299
|
|
|
246
300
|
var finalVideo = hasVideo ? _objectSpread(_objectSpread({}, video), {}, {
|
|
247
301
|
autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
|
|
@@ -265,10 +319,10 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
265
319
|
|
|
266
320
|
var hasThumbnail = thumbnailUrl !== null;
|
|
267
321
|
|
|
268
|
-
var
|
|
269
|
-
|
|
270
|
-
posterReady =
|
|
271
|
-
setPosterReady =
|
|
322
|
+
var _useState7 = useState(!hasThumbnail),
|
|
323
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
324
|
+
posterReady = _useState8[0],
|
|
325
|
+
setPosterReady = _useState8[1];
|
|
272
326
|
|
|
273
327
|
var withVideoSphere = hasVideoUrl && (isView || isEdit) && !isCapture && !isStatic;
|
|
274
328
|
|
|
@@ -337,13 +391,9 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
337
391
|
var geometry = new SphereBufferGeometry(500, 60, 40);
|
|
338
392
|
geometry.scale(-1, 1, 1);
|
|
339
393
|
|
|
340
|
-
var _ref8 =
|
|
341
|
-
_ref8$
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
var _ref9 = videoMediaRef || {},
|
|
345
|
-
_ref9$current = _ref9.current,
|
|
346
|
-
videoElement = _ref9$current === void 0 ? null : _ref9$current;
|
|
394
|
+
var _ref8 = mediaRef || {},
|
|
395
|
+
_ref8$current = _ref8.current,
|
|
396
|
+
videoElement = _ref8$current === void 0 ? null : _ref8$current;
|
|
347
397
|
|
|
348
398
|
var videoTexture = new VideoTexture(videoElement);
|
|
349
399
|
var videoMaterial = new MeshBasicMaterial({
|
|
@@ -385,38 +435,37 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
385
435
|
pointerDownX.current = e.clientX;
|
|
386
436
|
pointerDownY.current = e.clientY;
|
|
387
437
|
pointerLon.current = lon.current;
|
|
388
|
-
pointerLat.current = lat.current;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}, [togglePlay]);
|
|
438
|
+
pointerLat.current = lat.current; // if (togglePlayTimeout.current !== null) {
|
|
439
|
+
// clearTimeout(togglePlayTimeout.current);
|
|
440
|
+
// }
|
|
441
|
+
// togglePlayTimeout.current = setTimeout(() => {
|
|
442
|
+
// togglePlay();
|
|
443
|
+
// togglePlayTimeout.current = null;
|
|
444
|
+
// }, 300);
|
|
445
|
+
}, [
|
|
446
|
+
/* togglePlay */
|
|
447
|
+
]);
|
|
399
448
|
var pixelsMoved = useRef(0);
|
|
400
449
|
var lastPointerClient = useRef(null);
|
|
401
450
|
var pixelsMovedTracked = useRef(false);
|
|
402
451
|
var onPointerMove = useCallback(function (e) {
|
|
403
452
|
if (pointerDown.current) {
|
|
404
|
-
var
|
|
405
|
-
|
|
406
|
-
clientX =
|
|
407
|
-
|
|
408
|
-
clientY =
|
|
453
|
+
var _ref9 = e || {},
|
|
454
|
+
_ref9$clientX = _ref9.clientX,
|
|
455
|
+
clientX = _ref9$clientX === void 0 ? null : _ref9$clientX,
|
|
456
|
+
_ref9$clientY = _ref9.clientY,
|
|
457
|
+
clientY = _ref9$clientY === void 0 ? null : _ref9$clientY;
|
|
409
458
|
|
|
410
459
|
var downDeltaX = pointerDownX.current - clientX;
|
|
411
460
|
var downDeltaY = pointerDownY.current - clientY;
|
|
412
461
|
lon.current = downDeltaX * 0.2 + pointerLon.current;
|
|
413
462
|
lat.current = downDeltaY * 0.2 + pointerLat.current;
|
|
414
463
|
|
|
415
|
-
var
|
|
416
|
-
|
|
417
|
-
lastX =
|
|
418
|
-
|
|
419
|
-
lastY =
|
|
464
|
+
var _ref10 = lastPointerClient.current || {},
|
|
465
|
+
_ref10$x = _ref10.x,
|
|
466
|
+
lastX = _ref10$x === void 0 ? clientX : _ref10$x,
|
|
467
|
+
_ref10$y = _ref10.y,
|
|
468
|
+
lastY = _ref10$y === void 0 ? clientY : _ref10$y;
|
|
420
469
|
|
|
421
470
|
var deltaX = Math.abs(lastX - clientX) || 0;
|
|
422
471
|
var deltaY = Math.abs(lastY - clientY) || 0;
|
|
@@ -460,11 +509,11 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
460
509
|
var hasTappedLeft = e.clientX - containerX < containerWidth * (1 - tapNextScreenWidthPercent);
|
|
461
510
|
|
|
462
511
|
if (hasTappedLeft) {
|
|
463
|
-
if (
|
|
464
|
-
|
|
512
|
+
if (gotoPreviousScreen !== null) {
|
|
513
|
+
gotoPreviousScreen();
|
|
465
514
|
}
|
|
466
|
-
} else if (
|
|
467
|
-
|
|
515
|
+
} else if (gotoNextScreen !== null) {
|
|
516
|
+
gotoNextScreen();
|
|
468
517
|
}
|
|
469
518
|
}
|
|
470
519
|
|
|
@@ -475,8 +524,7 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
475
524
|
}
|
|
476
525
|
|
|
477
526
|
pointerDown.current = false;
|
|
478
|
-
}, [
|
|
479
|
-
var hasCallToAction = callToAction !== null && callToAction.active === true; // Building elements ------------------
|
|
527
|
+
}, [gotoPreviousScreen, gotoNextScreen, landscape]); // Building elements ------------------
|
|
480
528
|
|
|
481
529
|
var items = [/*#__PURE__*/React.createElement(ScreenElement, {
|
|
482
530
|
key: "video",
|
|
@@ -532,7 +580,14 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
532
580
|
resolution: resolution
|
|
533
581
|
})))), !isPlaceholder ? /*#__PURE__*/React.createElement("div", {
|
|
534
582
|
key: "bottom-content",
|
|
535
|
-
className: styles.
|
|
583
|
+
className: styles.bottom,
|
|
584
|
+
style: {
|
|
585
|
+
transform: !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
|
|
586
|
+
paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
587
|
+
paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
588
|
+
paddingBottom: spacing / 2,
|
|
589
|
+
paddingTop: 0
|
|
590
|
+
}
|
|
536
591
|
}, /*#__PURE__*/React.createElement(Transitions, {
|
|
537
592
|
playing: transitionPlaying,
|
|
538
593
|
transitions: transitions,
|
|
@@ -541,35 +596,17 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
541
596
|
className: styles.closedCaptions,
|
|
542
597
|
media: closedCaptions,
|
|
543
598
|
currentTime: currentTime
|
|
544
|
-
}) : null,
|
|
545
|
-
className: styles.
|
|
546
|
-
withSeekBar: withSeekBar,
|
|
547
|
-
withControls: withControls,
|
|
548
|
-
playing: playing,
|
|
549
|
-
muted: muted,
|
|
550
|
-
currentTime: currentTime,
|
|
551
|
-
duration: duration,
|
|
552
|
-
onTogglePlay: togglePlay,
|
|
553
|
-
onToggleMute: onToggleMute,
|
|
554
|
-
onSeek: seek,
|
|
555
|
-
focusable: current && isView
|
|
556
|
-
}) : null, hasCallToAction ? /*#__PURE__*/React.createElement("div", {
|
|
557
|
-
style: {
|
|
558
|
-
marginTop: -spacing / 2
|
|
559
|
-
}
|
|
560
|
-
}, /*#__PURE__*/React.createElement(CallToAction, {
|
|
561
|
-
callToAction: callToAction,
|
|
599
|
+
}) : null, hasCallToAction ? /*#__PURE__*/React.createElement(CallToAction, Object.assign({}, callToAction, {
|
|
600
|
+
className: styles.callToAction,
|
|
562
601
|
animationDisabled: isPreview,
|
|
563
602
|
focusable: current && isView,
|
|
564
|
-
screenSize: {
|
|
565
|
-
width: width,
|
|
566
|
-
height: height
|
|
567
|
-
},
|
|
568
603
|
enableInteraction: enableInteraction,
|
|
569
|
-
disableInteraction: disableInteraction
|
|
604
|
+
disableInteraction: disableInteraction,
|
|
605
|
+
openWebView: openWebView
|
|
570
606
|
})) : null)) : null];
|
|
571
607
|
return /*#__PURE__*/React.createElement("div", {
|
|
572
|
-
className: classNames([styles.container, (
|
|
608
|
+
className: classNames([styles.container, (_ref11 = {}, _defineProperty(_ref11, className, className !== null), _defineProperty(_ref11, styles.showVideo, isPreview || isStatic || isCapture), _ref11)]),
|
|
609
|
+
ref: activityDetectorRef,
|
|
573
610
|
"data-screen-ready": (isStatic || isCapture) && posterReady || ready
|
|
574
611
|
}, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
|
|
575
612
|
background: background,
|
|
@@ -591,17 +628,19 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
591
628
|
top: resizedVideoTop
|
|
592
629
|
}
|
|
593
630
|
}, /*#__PURE__*/React.createElement(Video, Object.assign({}, finalVideo, {
|
|
594
|
-
|
|
631
|
+
mediaRef: mediaRef,
|
|
595
632
|
className: styles.video,
|
|
633
|
+
paused: !current || !playing,
|
|
634
|
+
muted: muted,
|
|
596
635
|
withoutCors: true,
|
|
597
636
|
onReady: onVideoReady,
|
|
598
637
|
onPlay: onPlay,
|
|
599
638
|
onPause: onPause,
|
|
600
639
|
onTimeUpdate: onTimeUpdate,
|
|
601
640
|
onProgressStep: onProgressStep,
|
|
602
|
-
|
|
641
|
+
onDurationChange: onDurationChange,
|
|
603
642
|
onSeeked: onSeeked,
|
|
604
|
-
|
|
643
|
+
onEnded: onEnded,
|
|
605
644
|
onPosterLoaded: onPosterLoaded,
|
|
606
645
|
focusable: current && isView,
|
|
607
646
|
shouldLoad: mediaShouldLoad
|
package/lib/index.js
CHANGED
|
@@ -20,7 +20,6 @@ var CallToAction = require('@micromag/element-call-to-action');
|
|
|
20
20
|
var ClosedCaptions = require('@micromag/element-closed-captions');
|
|
21
21
|
var Container = require('@micromag/element-container');
|
|
22
22
|
var Image = require('@micromag/element-image');
|
|
23
|
-
var MediaControls = require('@micromag/element-media-controls');
|
|
24
23
|
var Video = require('@micromag/element-video');
|
|
25
24
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
26
25
|
var appleNews = require('@micromag/transforms/apple-news');
|
|
@@ -56,12 +55,9 @@ var CallToAction__default = /*#__PURE__*/_interopDefaultLegacy(CallToAction);
|
|
|
56
55
|
var ClosedCaptions__default = /*#__PURE__*/_interopDefaultLegacy(ClosedCaptions);
|
|
57
56
|
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
|
|
58
57
|
var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
|
|
59
|
-
var MediaControls__default = /*#__PURE__*/_interopDefaultLegacy(MediaControls);
|
|
60
58
|
var Video__default = /*#__PURE__*/_interopDefaultLegacy(Video);
|
|
61
59
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
62
60
|
|
|
63
|
-
var styles = {"container":"micromag-screen-video-360-container","canvasButton":"micromag-screen-video-360-canvasButton","canvas":"micromag-screen-video-360-canvas","content":"micromag-screen-video-360-content","placeholder":"micromag-screen-video-360-placeholder","video":"micromag-screen-video-360-video","disabled":"micromag-screen-video-360-disabled","hidden":"micromag-screen-video-360-hidden","empty":"micromag-screen-video-360-empty","videoContainer":"micromag-screen-video-360-videoContainer","mediaControls":"micromag-screen-video-360-mediaControls","bottomContent":"micromag-screen-video-360-bottomContent","showVideo":"micromag-screen-video-360-showVideo"};
|
|
64
|
-
|
|
65
61
|
/**
|
|
66
62
|
* Locale loader
|
|
67
63
|
*/
|
|
@@ -119,6 +115,8 @@ var useThree = function useThree() {
|
|
|
119
115
|
return loadedPackage;
|
|
120
116
|
};
|
|
121
117
|
|
|
118
|
+
var styles = {"container":"micromag-screen-video-360-container","canvasButton":"micromag-screen-video-360-canvasButton","canvas":"micromag-screen-video-360-canvas","content":"micromag-screen-video-360-content","placeholder":"micromag-screen-video-360-placeholder","video":"micromag-screen-video-360-video","disabled":"micromag-screen-video-360-disabled","hidden":"micromag-screen-video-360-hidden","empty":"micromag-screen-video-360-empty","videoContainer":"micromag-screen-video-360-videoContainer","mediaControls":"micromag-screen-video-360-mediaControls","bottom":"micromag-screen-video-360-bottom","showVideo":"micromag-screen-video-360-showVideo"};
|
|
119
|
+
|
|
122
120
|
var propTypes = {
|
|
123
121
|
layout: PropTypes__default["default"].oneOf(['full']),
|
|
124
122
|
video: core.PropTypes.videoElement,
|
|
@@ -127,12 +125,9 @@ var propTypes = {
|
|
|
127
125
|
current: PropTypes__default["default"].bool,
|
|
128
126
|
active: PropTypes__default["default"].bool,
|
|
129
127
|
transitions: core.PropTypes.transitions,
|
|
130
|
-
onPrevious: PropTypes__default["default"].func,
|
|
131
|
-
onNext: PropTypes__default["default"].func,
|
|
132
128
|
type: PropTypes__default["default"].string,
|
|
133
129
|
spacing: PropTypes__default["default"].number,
|
|
134
|
-
|
|
135
|
-
disableInteraction: PropTypes__default["default"].func,
|
|
130
|
+
mediaRef: PropTypes__default["default"].func,
|
|
136
131
|
className: PropTypes__default["default"].string
|
|
137
132
|
};
|
|
138
133
|
var defaultProps = {
|
|
@@ -143,17 +138,14 @@ var defaultProps = {
|
|
|
143
138
|
current: true,
|
|
144
139
|
active: true,
|
|
145
140
|
transitions: null,
|
|
146
|
-
onPrevious: null,
|
|
147
|
-
onNext: null,
|
|
148
141
|
type: null,
|
|
149
142
|
spacing: 20,
|
|
150
|
-
|
|
151
|
-
disableInteraction: null,
|
|
143
|
+
mediaRef: null,
|
|
152
144
|
className: null
|
|
153
145
|
};
|
|
154
146
|
|
|
155
147
|
var Video360Screen = function Video360Screen(_ref) {
|
|
156
|
-
var
|
|
148
|
+
var _ref11;
|
|
157
149
|
|
|
158
150
|
_ref.layout;
|
|
159
151
|
var video = _ref.video,
|
|
@@ -162,17 +154,26 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
162
154
|
current = _ref.current,
|
|
163
155
|
active = _ref.active,
|
|
164
156
|
transitions = _ref.transitions,
|
|
165
|
-
onPrevious = _ref.onPrevious,
|
|
166
|
-
onNext = _ref.onNext,
|
|
167
157
|
type = _ref.type,
|
|
168
158
|
spacing = _ref.spacing,
|
|
169
|
-
|
|
170
|
-
disableInteraction = _ref.disableInteraction,
|
|
159
|
+
customMediaRef = _ref.mediaRef,
|
|
171
160
|
className = _ref.className;
|
|
172
161
|
var THREE = useThree();
|
|
173
162
|
var trackScreenEvent = hooks.useTrackScreenEvent(type);
|
|
174
163
|
var trackScreenMedia = hooks.useTrackScreenMedia('video_360');
|
|
175
164
|
|
|
165
|
+
var _useViewerInteraction = contexts.useViewerInteraction(),
|
|
166
|
+
enableInteraction = _useViewerInteraction.enableInteraction,
|
|
167
|
+
disableInteraction = _useViewerInteraction.disableInteraction;
|
|
168
|
+
|
|
169
|
+
var _useViewerNavigation = contexts.useViewerNavigation(),
|
|
170
|
+
gotoPreviousScreen = _useViewerNavigation.gotoPreviousScreen,
|
|
171
|
+
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
172
|
+
|
|
173
|
+
var _useViewerContext = contexts.useViewerContext(),
|
|
174
|
+
viewerBottomHeight = _useViewerContext.bottomHeight,
|
|
175
|
+
viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
|
|
176
|
+
|
|
176
177
|
var _useScreenSize = contexts.useScreenSize(),
|
|
177
178
|
width = _useScreenSize.width,
|
|
178
179
|
height = _useScreenSize.height,
|
|
@@ -187,17 +188,102 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
187
188
|
isStatic = _useScreenRenderConte.isStatic,
|
|
188
189
|
isCapture = _useScreenRenderConte.isCapture;
|
|
189
190
|
|
|
191
|
+
var _useViewerWebView = contexts.useViewerWebView(),
|
|
192
|
+
openWebView = _useViewerWebView.open;
|
|
193
|
+
|
|
190
194
|
var backgroundPlaying = current && (isView || isEdit);
|
|
191
195
|
var mediaShouldLoad = current || active;
|
|
196
|
+
|
|
197
|
+
var _ref2 = video || {},
|
|
198
|
+
_ref2$media = _ref2.media,
|
|
199
|
+
videoMedia = _ref2$media === void 0 ? null : _ref2$media,
|
|
200
|
+
_ref2$closedCaptions = _ref2.closedCaptions,
|
|
201
|
+
closedCaptions = _ref2$closedCaptions === void 0 ? null : _ref2$closedCaptions,
|
|
202
|
+
_ref2$withSeekBar = _ref2.withSeekBar,
|
|
203
|
+
withSeekBar = _ref2$withSeekBar === void 0 ? false : _ref2$withSeekBar,
|
|
204
|
+
_ref2$withControls = _ref2.withControls,
|
|
205
|
+
withControls = _ref2$withControls === void 0 ? false : _ref2$withControls,
|
|
206
|
+
_ref2$autoPlay = _ref2.autoPlay,
|
|
207
|
+
autoPlay = _ref2$autoPlay === void 0 ? true : _ref2$autoPlay,
|
|
208
|
+
_ref2$color = _ref2.color,
|
|
209
|
+
color = _ref2$color === void 0 ? null : _ref2$color,
|
|
210
|
+
_ref2$progressColor = _ref2.progressColor,
|
|
211
|
+
progressColor = _ref2$progressColor === void 0 ? null : _ref2$progressColor;
|
|
212
|
+
|
|
192
213
|
var videoContainerRef = React.useRef();
|
|
193
|
-
var apiRef = React.useRef();
|
|
194
214
|
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
215
|
+
var _usePlaybackContext = contexts.usePlaybackContext(),
|
|
216
|
+
playing = _usePlaybackContext.playing,
|
|
217
|
+
muted = _usePlaybackContext.muted,
|
|
218
|
+
setControls = _usePlaybackContext.setControls,
|
|
219
|
+
setControlsTheme = _usePlaybackContext.setControlsTheme,
|
|
220
|
+
setMedia = _usePlaybackContext.setMedia,
|
|
221
|
+
setPlaying = _usePlaybackContext.setPlaying,
|
|
222
|
+
showControls = _usePlaybackContext.showControls,
|
|
223
|
+
hideControls = _usePlaybackContext.hideControls;
|
|
224
|
+
|
|
225
|
+
var mediaRef = React.useRef(null);
|
|
226
|
+
React.useEffect(function () {
|
|
227
|
+
if (!current) {
|
|
228
|
+
return function () {};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (withControls || withSeekBar) {
|
|
232
|
+
setControls(true);
|
|
233
|
+
setControlsTheme({
|
|
234
|
+
seekBarOnly: withSeekBar && !withControls,
|
|
235
|
+
color: color,
|
|
236
|
+
progressColor: progressColor
|
|
237
|
+
});
|
|
238
|
+
} else {
|
|
239
|
+
setControls(false);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return function () {
|
|
243
|
+
if (withControls || withSeekBar) {
|
|
244
|
+
setControls(false);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}, [current, withControls, setControls, withSeekBar, color, progressColor]);
|
|
248
|
+
React.useEffect(function () {
|
|
249
|
+
if (!current) {
|
|
250
|
+
return function () {};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
setMedia(mediaRef.current);
|
|
254
|
+
return function () {
|
|
255
|
+
setMedia(null);
|
|
256
|
+
};
|
|
257
|
+
}, [current]);
|
|
258
|
+
React.useEffect(function () {
|
|
259
|
+
if (customMediaRef !== null) {
|
|
260
|
+
customMediaRef(mediaRef.current);
|
|
261
|
+
}
|
|
262
|
+
}, [mediaRef.current]);
|
|
263
|
+
React.useEffect(function () {
|
|
264
|
+
if (current && autoPlay && !playing) {
|
|
265
|
+
setPlaying(true);
|
|
266
|
+
}
|
|
267
|
+
}, [current, autoPlay]);
|
|
268
|
+
|
|
269
|
+
var _useActivityDetector = hooks.useActivityDetector({
|
|
270
|
+
disabled: !current || !isView,
|
|
271
|
+
timeout: 2000
|
|
272
|
+
}),
|
|
273
|
+
activityDetectorRef = _useActivityDetector.ref,
|
|
274
|
+
activityDetected = _useActivityDetector.detected;
|
|
275
|
+
|
|
276
|
+
React.useEffect(function () {
|
|
277
|
+
if (!current) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (activityDetected) {
|
|
282
|
+
showControls();
|
|
283
|
+
} else {
|
|
284
|
+
hideControls();
|
|
285
|
+
}
|
|
286
|
+
}, [activityDetected, showControls, hideControls]);
|
|
201
287
|
|
|
202
288
|
var _useState = React.useState(null),
|
|
203
289
|
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
@@ -209,78 +295,45 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
209
295
|
duration = _useState4[0],
|
|
210
296
|
setDuration = _useState4[1];
|
|
211
297
|
|
|
212
|
-
var _useState5 = React.useState(false),
|
|
213
|
-
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
214
|
-
playing = _useState6[0],
|
|
215
|
-
setPlaying = _useState6[1];
|
|
216
|
-
|
|
217
|
-
var _useState7 = React.useState(false),
|
|
218
|
-
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
219
|
-
muted = _useState8[0],
|
|
220
|
-
setMuted = _useState8[1];
|
|
221
|
-
|
|
222
298
|
var onTimeUpdate = React.useCallback(function (time) {
|
|
223
299
|
setCurrentTime(time);
|
|
224
300
|
}, [setDuration, duration]);
|
|
225
301
|
var onProgressStep = React.useCallback(function (step) {
|
|
226
302
|
trackScreenMedia(video, "progress_".concat(Math.round(step * 100, 10), "%"));
|
|
227
303
|
}, [trackScreenMedia, video]);
|
|
228
|
-
var
|
|
304
|
+
var onDurationChange = React.useCallback(function (dur) {
|
|
229
305
|
setDuration(dur);
|
|
230
306
|
}, [setDuration]);
|
|
231
307
|
var onPlay = React.useCallback(function (_ref3) {
|
|
232
308
|
var initial = _ref3.initial;
|
|
233
|
-
setPlaying(true);
|
|
234
309
|
trackScreenMedia(video, initial ? 'play' : 'resume');
|
|
235
310
|
}, [trackScreenMedia, video]);
|
|
236
311
|
var onPause = React.useCallback(function (_ref4) {
|
|
237
312
|
var midway = _ref4.midway;
|
|
238
|
-
setPlaying(false);
|
|
239
313
|
trackScreenMedia(video, midway ? 'pause' : 'ended');
|
|
240
314
|
}, [trackScreenMedia, video]);
|
|
241
|
-
var onVolumeChanged = React.useCallback(function (isMuted) {
|
|
242
|
-
setMuted(isMuted);
|
|
243
|
-
trackScreenMedia(video, isMuted ? 'mute' : 'unmute');
|
|
244
|
-
}, [trackScreenMedia, video]);
|
|
245
315
|
var onSeeked = React.useCallback(function (time) {
|
|
246
316
|
if (time > 0) {
|
|
247
317
|
trackScreenMedia(video, 'seek');
|
|
248
318
|
}
|
|
249
319
|
}, [trackScreenMedia, video]);
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
toggleMute();
|
|
256
|
-
}, [muted, toggleMute]);
|
|
257
|
-
React.useEffect(function () {
|
|
258
|
-
if (!current && playing) {
|
|
259
|
-
pause();
|
|
260
|
-
}
|
|
261
|
-
}, [playing, current]); // ------------------------------------
|
|
320
|
+
var onEnded = React.useCallback(function () {
|
|
321
|
+
setPlaying(false);
|
|
322
|
+
}, [setPlaying]); // ------------------------------------
|
|
262
323
|
|
|
263
324
|
var hasVideo = video !== null;
|
|
264
325
|
|
|
265
|
-
var
|
|
266
|
-
|
|
267
|
-
ready =
|
|
268
|
-
setReady =
|
|
326
|
+
var _useState5 = React.useState(!hasVideo),
|
|
327
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
328
|
+
ready = _useState6[0],
|
|
329
|
+
setReady = _useState6[1];
|
|
269
330
|
|
|
270
331
|
var transitionPlaying = current && ready;
|
|
271
332
|
var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
|
|
272
333
|
|
|
273
|
-
var _ref5 =
|
|
274
|
-
_ref5$
|
|
275
|
-
|
|
276
|
-
_ref5$closedCaptions = _ref5.closedCaptions,
|
|
277
|
-
closedCaptions = _ref5$closedCaptions === void 0 ? null : _ref5$closedCaptions,
|
|
278
|
-
_ref5$withSeekBar = _ref5.withSeekBar,
|
|
279
|
-
withSeekBar = _ref5$withSeekBar === void 0 ? false : _ref5$withSeekBar,
|
|
280
|
-
_ref5$withControls = _ref5.withControls,
|
|
281
|
-
withControls = _ref5$withControls === void 0 ? false : _ref5$withControls,
|
|
282
|
-
_ref5$autoPlay = _ref5.autoPlay,
|
|
283
|
-
autoPlay = _ref5$autoPlay === void 0 ? true : _ref5$autoPlay;
|
|
334
|
+
var _ref5 = callToAction || {},
|
|
335
|
+
_ref5$active = _ref5.active,
|
|
336
|
+
hasCallToAction = _ref5$active === void 0 ? false : _ref5$active;
|
|
284
337
|
|
|
285
338
|
var finalVideo = hasVideo ? _objectSpread__default["default"](_objectSpread__default["default"]({}, video), {}, {
|
|
286
339
|
autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
|
|
@@ -304,10 +357,10 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
304
357
|
|
|
305
358
|
var hasThumbnail = thumbnailUrl !== null;
|
|
306
359
|
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
posterReady =
|
|
310
|
-
setPosterReady =
|
|
360
|
+
var _useState7 = React.useState(!hasThumbnail),
|
|
361
|
+
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
362
|
+
posterReady = _useState8[0],
|
|
363
|
+
setPosterReady = _useState8[1];
|
|
311
364
|
|
|
312
365
|
var withVideoSphere = hasVideoUrl && (isView || isEdit) && !isCapture && !isStatic;
|
|
313
366
|
|
|
@@ -376,13 +429,9 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
376
429
|
var geometry = new SphereBufferGeometry(500, 60, 40);
|
|
377
430
|
geometry.scale(-1, 1, 1);
|
|
378
431
|
|
|
379
|
-
var _ref8 =
|
|
380
|
-
_ref8$
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
var _ref9 = videoMediaRef || {},
|
|
384
|
-
_ref9$current = _ref9.current,
|
|
385
|
-
videoElement = _ref9$current === void 0 ? null : _ref9$current;
|
|
432
|
+
var _ref8 = mediaRef || {},
|
|
433
|
+
_ref8$current = _ref8.current,
|
|
434
|
+
videoElement = _ref8$current === void 0 ? null : _ref8$current;
|
|
386
435
|
|
|
387
436
|
var videoTexture = new VideoTexture(videoElement);
|
|
388
437
|
var videoMaterial = new MeshBasicMaterial({
|
|
@@ -424,38 +473,37 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
424
473
|
pointerDownX.current = e.clientX;
|
|
425
474
|
pointerDownY.current = e.clientY;
|
|
426
475
|
pointerLon.current = lon.current;
|
|
427
|
-
pointerLat.current = lat.current;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}, [togglePlay]);
|
|
476
|
+
pointerLat.current = lat.current; // if (togglePlayTimeout.current !== null) {
|
|
477
|
+
// clearTimeout(togglePlayTimeout.current);
|
|
478
|
+
// }
|
|
479
|
+
// togglePlayTimeout.current = setTimeout(() => {
|
|
480
|
+
// togglePlay();
|
|
481
|
+
// togglePlayTimeout.current = null;
|
|
482
|
+
// }, 300);
|
|
483
|
+
}, [
|
|
484
|
+
/* togglePlay */
|
|
485
|
+
]);
|
|
438
486
|
var pixelsMoved = React.useRef(0);
|
|
439
487
|
var lastPointerClient = React.useRef(null);
|
|
440
488
|
var pixelsMovedTracked = React.useRef(false);
|
|
441
489
|
var onPointerMove = React.useCallback(function (e) {
|
|
442
490
|
if (pointerDown.current) {
|
|
443
|
-
var
|
|
444
|
-
|
|
445
|
-
clientX =
|
|
446
|
-
|
|
447
|
-
clientY =
|
|
491
|
+
var _ref9 = e || {},
|
|
492
|
+
_ref9$clientX = _ref9.clientX,
|
|
493
|
+
clientX = _ref9$clientX === void 0 ? null : _ref9$clientX,
|
|
494
|
+
_ref9$clientY = _ref9.clientY,
|
|
495
|
+
clientY = _ref9$clientY === void 0 ? null : _ref9$clientY;
|
|
448
496
|
|
|
449
497
|
var downDeltaX = pointerDownX.current - clientX;
|
|
450
498
|
var downDeltaY = pointerDownY.current - clientY;
|
|
451
499
|
lon.current = downDeltaX * 0.2 + pointerLon.current;
|
|
452
500
|
lat.current = downDeltaY * 0.2 + pointerLat.current;
|
|
453
501
|
|
|
454
|
-
var
|
|
455
|
-
|
|
456
|
-
lastX =
|
|
457
|
-
|
|
458
|
-
lastY =
|
|
502
|
+
var _ref10 = lastPointerClient.current || {},
|
|
503
|
+
_ref10$x = _ref10.x,
|
|
504
|
+
lastX = _ref10$x === void 0 ? clientX : _ref10$x,
|
|
505
|
+
_ref10$y = _ref10.y,
|
|
506
|
+
lastY = _ref10$y === void 0 ? clientY : _ref10$y;
|
|
459
507
|
|
|
460
508
|
var deltaX = Math.abs(lastX - clientX) || 0;
|
|
461
509
|
var deltaY = Math.abs(lastY - clientY) || 0;
|
|
@@ -499,11 +547,11 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
499
547
|
var hasTappedLeft = e.clientX - containerX < containerWidth * (1 - tapNextScreenWidthPercent);
|
|
500
548
|
|
|
501
549
|
if (hasTappedLeft) {
|
|
502
|
-
if (
|
|
503
|
-
|
|
550
|
+
if (gotoPreviousScreen !== null) {
|
|
551
|
+
gotoPreviousScreen();
|
|
504
552
|
}
|
|
505
|
-
} else if (
|
|
506
|
-
|
|
553
|
+
} else if (gotoNextScreen !== null) {
|
|
554
|
+
gotoNextScreen();
|
|
507
555
|
}
|
|
508
556
|
}
|
|
509
557
|
|
|
@@ -514,8 +562,7 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
514
562
|
}
|
|
515
563
|
|
|
516
564
|
pointerDown.current = false;
|
|
517
|
-
}, [
|
|
518
|
-
var hasCallToAction = callToAction !== null && callToAction.active === true; // Building elements ------------------
|
|
565
|
+
}, [gotoPreviousScreen, gotoNextScreen, landscape]); // Building elements ------------------
|
|
519
566
|
|
|
520
567
|
var items = [/*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
521
568
|
key: "video",
|
|
@@ -571,7 +618,14 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
571
618
|
resolution: resolution
|
|
572
619
|
})))), !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
573
620
|
key: "bottom-content",
|
|
574
|
-
className: styles.
|
|
621
|
+
className: styles.bottom,
|
|
622
|
+
style: {
|
|
623
|
+
transform: !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
|
|
624
|
+
paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
625
|
+
paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
626
|
+
paddingBottom: spacing / 2,
|
|
627
|
+
paddingTop: 0
|
|
628
|
+
}
|
|
575
629
|
}, /*#__PURE__*/React__default["default"].createElement(components.Transitions, {
|
|
576
630
|
playing: transitionPlaying,
|
|
577
631
|
transitions: transitions,
|
|
@@ -580,35 +634,17 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
580
634
|
className: styles.closedCaptions,
|
|
581
635
|
media: closedCaptions,
|
|
582
636
|
currentTime: currentTime
|
|
583
|
-
}) : null,
|
|
584
|
-
className: styles.
|
|
585
|
-
withSeekBar: withSeekBar,
|
|
586
|
-
withControls: withControls,
|
|
587
|
-
playing: playing,
|
|
588
|
-
muted: muted,
|
|
589
|
-
currentTime: currentTime,
|
|
590
|
-
duration: duration,
|
|
591
|
-
onTogglePlay: togglePlay,
|
|
592
|
-
onToggleMute: onToggleMute,
|
|
593
|
-
onSeek: seek,
|
|
594
|
-
focusable: current && isView
|
|
595
|
-
}) : null, hasCallToAction ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
596
|
-
style: {
|
|
597
|
-
marginTop: -spacing / 2
|
|
598
|
-
}
|
|
599
|
-
}, /*#__PURE__*/React__default["default"].createElement(CallToAction__default["default"], {
|
|
600
|
-
callToAction: callToAction,
|
|
637
|
+
}) : null, hasCallToAction ? /*#__PURE__*/React__default["default"].createElement(CallToAction__default["default"], Object.assign({}, callToAction, {
|
|
638
|
+
className: styles.callToAction,
|
|
601
639
|
animationDisabled: isPreview,
|
|
602
640
|
focusable: current && isView,
|
|
603
|
-
screenSize: {
|
|
604
|
-
width: width,
|
|
605
|
-
height: height
|
|
606
|
-
},
|
|
607
641
|
enableInteraction: enableInteraction,
|
|
608
|
-
disableInteraction: disableInteraction
|
|
642
|
+
disableInteraction: disableInteraction,
|
|
643
|
+
openWebView: openWebView
|
|
609
644
|
})) : null)) : null];
|
|
610
645
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
611
|
-
className: classNames__default["default"]([styles.container, (
|
|
646
|
+
className: classNames__default["default"]([styles.container, (_ref11 = {}, _defineProperty__default["default"](_ref11, className, className !== null), _defineProperty__default["default"](_ref11, styles.showVideo, isPreview || isStatic || isCapture), _ref11)]),
|
|
647
|
+
ref: activityDetectorRef,
|
|
612
648
|
"data-screen-ready": (isStatic || isCapture) && posterReady || ready
|
|
613
649
|
}, !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
|
|
614
650
|
background: background,
|
|
@@ -630,17 +666,19 @@ var Video360Screen = function Video360Screen(_ref) {
|
|
|
630
666
|
top: resizedVideoTop
|
|
631
667
|
}
|
|
632
668
|
}, /*#__PURE__*/React__default["default"].createElement(Video__default["default"], Object.assign({}, finalVideo, {
|
|
633
|
-
|
|
669
|
+
mediaRef: mediaRef,
|
|
634
670
|
className: styles.video,
|
|
671
|
+
paused: !current || !playing,
|
|
672
|
+
muted: muted,
|
|
635
673
|
withoutCors: true,
|
|
636
674
|
onReady: onVideoReady,
|
|
637
675
|
onPlay: onPlay,
|
|
638
676
|
onPause: onPause,
|
|
639
677
|
onTimeUpdate: onTimeUpdate,
|
|
640
678
|
onProgressStep: onProgressStep,
|
|
641
|
-
|
|
679
|
+
onDurationChange: onDurationChange,
|
|
642
680
|
onSeeked: onSeeked,
|
|
643
|
-
|
|
681
|
+
onEnded: onEnded,
|
|
644
682
|
onPosterLoaded: onPosterLoaded,
|
|
645
683
|
focusable: current && isView,
|
|
646
684
|
shouldLoad: mediaShouldLoad
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-video-360",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.152",
|
|
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.
|
|
54
|
-
"@micromag/element-background": "^0.3.
|
|
55
|
-
"@micromag/element-call-to-action": "^0.3.
|
|
56
|
-
"@micromag/element-closed-captions": "^0.3.
|
|
57
|
-
"@micromag/element-container": "^0.3.
|
|
58
|
-
"@micromag/element-image": "^0.3.
|
|
59
|
-
"@micromag/element-media-controls": "^0.3.
|
|
60
|
-
"@micromag/element-video": "^0.3.
|
|
61
|
-
"@micromag/transforms": "^0.3.
|
|
53
|
+
"@micromag/core": "^0.3.152",
|
|
54
|
+
"@micromag/element-background": "^0.3.152",
|
|
55
|
+
"@micromag/element-call-to-action": "^0.3.152",
|
|
56
|
+
"@micromag/element-closed-captions": "^0.3.152",
|
|
57
|
+
"@micromag/element-container": "^0.3.152",
|
|
58
|
+
"@micromag/element-image": "^0.3.152",
|
|
59
|
+
"@micromag/element-media-controls": "^0.3.152",
|
|
60
|
+
"@micromag/element-video": "^0.3.152",
|
|
61
|
+
"@micromag/transforms": "^0.3.152",
|
|
62
62
|
"classnames": "^2.2.6",
|
|
63
63
|
"lodash": "^4.17.21",
|
|
64
64
|
"prop-types": "^15.7.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "23db6c104c10cc70a73366c8b04576a312a36206"
|
|
74
74
|
}
|