@micromag/screen-video 0.2.409 → 0.3.1
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 +79 -30
- package/lib/index.js +83 -34
- package/package.json +11 -11
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.micromag-screen-video-container .micromag-screen-video-content,.micromag-screen-video-container .micromag-screen-video-empty,.micromag-screen-video-container .micromag-screen-video-emptyContainer,.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-image,.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-placeholder,.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-video{position:absolute;top:0;left:0;width:100%;height:100%}.micromag-screen-video-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-video-disabled.micromag-screen-video-container{overflow:hidden;pointer-events:none}.micromag-screen-video-hidden.micromag-screen-video-container{display:none;visibility:hidden}.micromag-screen-video-placeholder.micromag-screen-video-container .micromag-screen-video-content{position:relative;padding:6px}.micromag-screen-video-container .micromag-screen-video-empty{margin:5px auto;border:2px dashed #343434;color:#343434}.micromag-screen-video-container .micromag-screen-video-emptyContainer{top:50%;height:0;padding-bottom:56.25%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%)}.micromag-screen-video-container .micromag-screen-video-empty{margin:0}.micromag-screen-video-container .micromag-screen-video-content{overflow:hidden}.micromag-screen-video-container .micromag-screen-video-mediaControls{padding:10px 20px 20px}.micromag-screen-video-container .micromag-screen-video-placeholder{display:-webkit-flex;display:-ms-flexbox;display:flex
|
|
1
|
+
.micromag-screen-video-container .micromag-screen-video-content,.micromag-screen-video-container .micromag-screen-video-empty,.micromag-screen-video-container .micromag-screen-video-emptyContainer,.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-image,.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-placeholder,.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-video{position:absolute;top:0;left:0;width:100%;height:100%}.micromag-screen-video-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-video-disabled.micromag-screen-video-container{overflow:hidden;pointer-events:none}.micromag-screen-video-hidden.micromag-screen-video-container{display:none;visibility:hidden}.micromag-screen-video-placeholder.micromag-screen-video-container .micromag-screen-video-content{position:relative;padding:6px}.micromag-screen-video-container .micromag-screen-video-empty{margin:5px auto;border:2px dashed #343434;color:#343434}.micromag-screen-video-container .micromag-screen-video-emptyContainer{top:50%;height:0;padding-bottom:56.25%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%)}.micromag-screen-video-container .micromag-screen-video-empty{margin:0}.micromag-screen-video-container .micromag-screen-video-content{overflow:hidden}.micromag-screen-video-container .micromag-screen-video-mediaControls{padding:10px 20px 20px;opacity:0;-webkit-transition:opacity .3s linear;-o-transition:opacity .3s linear;transition:opacity .3s linear}.micromag-screen-video-container .micromag-screen-video-mediaControls.micromag-screen-video-visible{opacity:1}.micromag-screen-video-container .micromag-screen-video-placeholder{display:-webkit-flex;display:-ms-flexbox;display:flex;height:100%;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.micromag-screen-video-container .micromag-screen-video-videoContainer{position:absolute}.micromag-screen-video-container .micromag-screen-video-bottomContent{position:absolute;bottom:0;width:100%}.micromag-screen-video-container.micromag-screen-video-fullscreen .micromag-screen-video-emptyContainer{top:0;height:100%;padding-bottom:0;-webkit-transform:none;-ms-transform:none;transform:none}
|
package/es/index.js
CHANGED
|
@@ -2,29 +2,30 @@ import { FormattedMessage, defineMessage } from 'react-intl';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
-
import React, { useRef, useEffect, useState, useCallback, useMemo } from 'react';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
5
|
import { getSizeWithinBounds } from '@folklore/size';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React, { useRef, useEffect, useState, useCallback, useMemo } from 'react';
|
|
9
9
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
10
10
|
import { ScreenElement, PlaceholderVideo, Empty, Transitions } from '@micromag/core/components';
|
|
11
|
-
import { useScreenSize, useScreenRenderContext } from '@micromag/core/contexts';
|
|
11
|
+
import { useScreenSize, useScreenRenderContext, useViewerNavigation } from '@micromag/core/contexts';
|
|
12
12
|
import { useTrackScreenMedia, useLongPress } from '@micromag/core/hooks';
|
|
13
13
|
import Background from '@micromag/element-background';
|
|
14
|
-
import
|
|
14
|
+
import CallToAction from '@micromag/element-call-to-action';
|
|
15
15
|
import ClosedCaptions from '@micromag/element-closed-captions';
|
|
16
|
-
import
|
|
16
|
+
import Container from '@micromag/element-container';
|
|
17
17
|
import Image from '@micromag/element-image';
|
|
18
|
+
import MediaControls from '@micromag/element-media-controls';
|
|
18
19
|
import Video from '@micromag/element-video';
|
|
19
|
-
import CallToAction from '@micromag/element-call-to-action';
|
|
20
20
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
21
21
|
import { Video as Video$1, Container as Container$1 } from '@micromag/transforms/apple-news';
|
|
22
22
|
|
|
23
|
-
var styles = {"container":"micromag-screen-video-container","content":"micromag-screen-video-content","empty":"micromag-screen-video-empty","emptyContainer":"micromag-screen-video-emptyContainer","fullscreen":"micromag-screen-video-fullscreen","image":"micromag-screen-video-image","placeholder":"micromag-screen-video-placeholder","video":"micromag-screen-video-video","disabled":"micromag-screen-video-disabled","hidden":"micromag-screen-video-hidden","mediaControls":"micromag-screen-video-mediaControls","videoContainer":"micromag-screen-video-videoContainer","bottomContent":"micromag-screen-video-bottomContent"};
|
|
23
|
+
var styles = {"container":"micromag-screen-video-container","content":"micromag-screen-video-content","empty":"micromag-screen-video-empty","emptyContainer":"micromag-screen-video-emptyContainer","fullscreen":"micromag-screen-video-fullscreen","image":"micromag-screen-video-image","placeholder":"micromag-screen-video-placeholder","video":"micromag-screen-video-video","disabled":"micromag-screen-video-disabled","hidden":"micromag-screen-video-hidden","mediaControls":"micromag-screen-video-mediaControls","visible":"micromag-screen-video-visible","videoContainer":"micromag-screen-video-videoContainer","bottomContent":"micromag-screen-video-bottomContent"};
|
|
24
24
|
|
|
25
25
|
var propTypes = {
|
|
26
26
|
layout: PropTypes.oneOf(['middle', 'full']),
|
|
27
27
|
video: PropTypes$1.videoElement,
|
|
28
|
+
gotoNextScreenOnEnd: PropTypes.bool,
|
|
28
29
|
background: PropTypes$1.backgroundElement,
|
|
29
30
|
callToAction: PropTypes$1.callToAction,
|
|
30
31
|
current: PropTypes.bool,
|
|
@@ -37,6 +38,7 @@ var propTypes = {
|
|
|
37
38
|
var defaultProps = {
|
|
38
39
|
layout: 'middle',
|
|
39
40
|
video: null,
|
|
41
|
+
gotoNextScreenOnEnd: false,
|
|
40
42
|
background: null,
|
|
41
43
|
callToAction: null,
|
|
42
44
|
current: true,
|
|
@@ -48,10 +50,11 @@ var defaultProps = {
|
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
var VideoScreen = function VideoScreen(_ref) {
|
|
51
|
-
var
|
|
53
|
+
var _ref9;
|
|
52
54
|
|
|
53
55
|
var layout = _ref.layout,
|
|
54
56
|
video = _ref.video,
|
|
57
|
+
gotoNextScreenOnEnd = _ref.gotoNextScreenOnEnd,
|
|
55
58
|
background = _ref.background,
|
|
56
59
|
callToAction = _ref.callToAction,
|
|
57
60
|
current = _ref.current,
|
|
@@ -74,9 +77,13 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
74
77
|
isStatic = _useScreenRenderConte.isStatic,
|
|
75
78
|
isCapture = _useScreenRenderConte.isCapture;
|
|
76
79
|
|
|
80
|
+
var _useViewerNavigation = useViewerNavigation(),
|
|
81
|
+
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
82
|
+
|
|
77
83
|
var backgroundPlaying = current && (isView || isEdit);
|
|
78
84
|
var backgroundShouldLoad = current || active || !isView;
|
|
79
85
|
var videoShouldLoad = current || active || !isView;
|
|
86
|
+
var shouldGotoNextScreenOnEnd = gotoNextScreenOnEnd && isView && current;
|
|
80
87
|
var apiRef = useRef();
|
|
81
88
|
|
|
82
89
|
var _ref2 = apiRef.current || {},
|
|
@@ -92,27 +99,34 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
92
99
|
if (apiMediaRef !== null && getMediaRef !== null) {
|
|
93
100
|
getMediaRef(apiMediaRef.current);
|
|
94
101
|
}
|
|
95
|
-
}, [apiMediaRef, getMediaRef]);
|
|
102
|
+
}, [apiMediaRef, getMediaRef]);
|
|
103
|
+
var mouseMoveRef = useRef(null);
|
|
96
104
|
|
|
97
|
-
var _useState = useState(
|
|
105
|
+
var _useState = useState(false),
|
|
98
106
|
_useState2 = _slicedToArray(_useState, 2),
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
showMediaControls = _useState2[0],
|
|
108
|
+
setShowMediaControls = _useState2[1]; // Get api state updates from callback
|
|
109
|
+
|
|
101
110
|
|
|
102
111
|
var _useState3 = useState(null),
|
|
103
112
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
currentTime = _useState4[0],
|
|
114
|
+
setCurrentTime = _useState4[1];
|
|
106
115
|
|
|
107
|
-
var _useState5 = useState(
|
|
116
|
+
var _useState5 = useState(null),
|
|
108
117
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
duration = _useState6[0],
|
|
119
|
+
setDuration = _useState6[1];
|
|
111
120
|
|
|
112
121
|
var _useState7 = useState(false),
|
|
113
122
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
playing = _useState8[0],
|
|
124
|
+
setPlaying = _useState8[1];
|
|
125
|
+
|
|
126
|
+
var _useState9 = useState(false),
|
|
127
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
128
|
+
muted = _useState10[0],
|
|
129
|
+
setMuted = _useState10[1];
|
|
116
130
|
|
|
117
131
|
var onTimeUpdate = useCallback(function (time) {
|
|
118
132
|
setCurrentTime(time);
|
|
@@ -149,23 +163,41 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
149
163
|
|
|
150
164
|
toggleMute();
|
|
151
165
|
}, [muted, toggleMute]);
|
|
166
|
+
var onEnded = useCallback(function () {
|
|
167
|
+
if (shouldGotoNextScreenOnEnd) {
|
|
168
|
+
gotoNextScreen();
|
|
169
|
+
}
|
|
170
|
+
}, [shouldGotoNextScreenOnEnd, seek, gotoNextScreen]);
|
|
152
171
|
useEffect(function () {
|
|
153
172
|
if (!current && playing) {
|
|
154
173
|
pause();
|
|
155
174
|
}
|
|
156
|
-
}, [playing, current]);
|
|
175
|
+
}, [playing, current]);
|
|
176
|
+
var onMouseMove = useCallback(function () {
|
|
177
|
+
setShowMediaControls(true);
|
|
178
|
+
|
|
179
|
+
if (mouseMoveRef.current !== null) {
|
|
180
|
+
clearTimeout(mouseMoveRef.current);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
mouseMoveRef.current = setTimeout(function () {
|
|
184
|
+
setShowMediaControls(false);
|
|
185
|
+
mouseMoveRef.current = null;
|
|
186
|
+
}, 1800);
|
|
187
|
+
}, [setShowMediaControls]); // ------------------------------------
|
|
157
188
|
|
|
158
189
|
var longPressBind = useLongPress({
|
|
159
|
-
onLongPress: togglePlay
|
|
190
|
+
onLongPress: togglePlay,
|
|
191
|
+
onClick: onMouseMove
|
|
160
192
|
});
|
|
161
193
|
var fullscreen = layout === 'full';
|
|
162
194
|
var hasCallToAction = callToAction !== null && callToAction.active === true;
|
|
163
195
|
var hasVideo = video !== null;
|
|
164
196
|
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
ready =
|
|
168
|
-
setReady =
|
|
197
|
+
var _useState11 = useState(hasVideo),
|
|
198
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
199
|
+
ready = _useState12[0],
|
|
200
|
+
setReady = _useState12[1]; // useState(!hasVideo);
|
|
169
201
|
|
|
170
202
|
|
|
171
203
|
var transitionPlaying = current && ready;
|
|
@@ -181,7 +213,9 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
181
213
|
_ref5$withSeekBar = _ref5.withSeekBar,
|
|
182
214
|
withSeekBar = _ref5$withSeekBar === void 0 ? false : _ref5$withSeekBar,
|
|
183
215
|
_ref5$withPlayPause = _ref5.withPlayPause,
|
|
184
|
-
withPlayPause = _ref5$withPlayPause === void 0 ? false : _ref5$withPlayPause
|
|
216
|
+
withPlayPause = _ref5$withPlayPause === void 0 ? false : _ref5$withPlayPause,
|
|
217
|
+
_ref5$withTime = _ref5.withTime,
|
|
218
|
+
withTime = _ref5$withTime === void 0 ? false : _ref5$withTime;
|
|
185
219
|
|
|
186
220
|
var finalVideo = useMemo(function () {
|
|
187
221
|
return hasVideo ? _objectSpread(_objectSpread({}, video), {}, {
|
|
@@ -278,6 +312,7 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
278
312
|
onProgressStep: onProgressStep,
|
|
279
313
|
onDurationChanged: onDurationChanged,
|
|
280
314
|
onSeeked: onSeeked,
|
|
315
|
+
onEnded: onEnded,
|
|
281
316
|
onVolumeChanged: onVolumeChanged,
|
|
282
317
|
focusable: current && isView,
|
|
283
318
|
preload: videoShouldLoad ? 'auto' : 'metadata' // onPosterLoaded={onPosterLoaded}
|
|
@@ -294,9 +329,10 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
294
329
|
media: closedCaptions,
|
|
295
330
|
currentTime: currentTime
|
|
296
331
|
}) : null, hasVideoUrl ? /*#__PURE__*/React.createElement(MediaControls, {
|
|
297
|
-
className: styles.mediaControls,
|
|
332
|
+
className: classNames([styles.mediaControls, _defineProperty({}, styles.visible, !autoPlay && !playing || muted || showMediaControls)]),
|
|
298
333
|
withSeekBar: withSeekBar,
|
|
299
334
|
withPlayPause: withPlayPause,
|
|
335
|
+
withTime: withTime,
|
|
300
336
|
playing: playing,
|
|
301
337
|
muted: muted,
|
|
302
338
|
currentTime: currentTime,
|
|
@@ -315,11 +351,13 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
315
351
|
focusable: current && isView
|
|
316
352
|
})) : null)) : null];
|
|
317
353
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
318
|
-
className: classNames([styles.container, (
|
|
354
|
+
className: classNames([styles.container, (_ref9 = {}, _defineProperty(_ref9, className, className !== null), _defineProperty(_ref9, styles.fullscreen, fullscreen), _ref9)]),
|
|
319
355
|
"data-screen-ready": isStatic || isCapture
|
|
320
356
|
/* && posterReady */
|
|
321
357
|
|| ready
|
|
322
|
-
}, longPressBind
|
|
358
|
+
}, longPressBind, {
|
|
359
|
+
onMouseMove: onMouseMove
|
|
360
|
+
}), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
|
|
323
361
|
background: background,
|
|
324
362
|
width: width,
|
|
325
363
|
height: height,
|
|
@@ -414,6 +452,17 @@ var definition = {
|
|
|
414
452
|
"value": "Video"
|
|
415
453
|
}]
|
|
416
454
|
})
|
|
455
|
+
}, {
|
|
456
|
+
name: 'gotoNextScreenOnEnd',
|
|
457
|
+
type: 'toggle',
|
|
458
|
+
defaultValue: false,
|
|
459
|
+
label: defineMessage({
|
|
460
|
+
id: "n8zmLY",
|
|
461
|
+
defaultMessage: [{
|
|
462
|
+
"type": 0,
|
|
463
|
+
"value": "Go to next screen on end"
|
|
464
|
+
}]
|
|
465
|
+
})
|
|
417
466
|
}, {
|
|
418
467
|
name: 'background',
|
|
419
468
|
type: 'background',
|
package/lib/index.js
CHANGED
|
@@ -6,21 +6,21 @@ var reactIntl = require('react-intl');
|
|
|
6
6
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
7
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
8
8
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var PropTypes = require('prop-types');
|
|
11
|
-
var classNames = require('classnames');
|
|
12
9
|
var size = require('@folklore/size');
|
|
10
|
+
var classNames = require('classnames');
|
|
11
|
+
var PropTypes = require('prop-types');
|
|
12
|
+
var React = require('react');
|
|
13
13
|
var core = require('@micromag/core');
|
|
14
14
|
var components = require('@micromag/core/components');
|
|
15
15
|
var contexts = require('@micromag/core/contexts');
|
|
16
16
|
var hooks = require('@micromag/core/hooks');
|
|
17
17
|
var Background = require('@micromag/element-background');
|
|
18
|
-
var
|
|
18
|
+
var CallToAction = require('@micromag/element-call-to-action');
|
|
19
19
|
var ClosedCaptions = require('@micromag/element-closed-captions');
|
|
20
|
-
var
|
|
20
|
+
var Container = require('@micromag/element-container');
|
|
21
21
|
var Image = require('@micromag/element-image');
|
|
22
|
+
var MediaControls = require('@micromag/element-media-controls');
|
|
22
23
|
var Video = require('@micromag/element-video');
|
|
23
|
-
var CallToAction = require('@micromag/element-call-to-action');
|
|
24
24
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
25
25
|
var appleNews = require('@micromag/transforms/apple-news');
|
|
26
26
|
|
|
@@ -29,23 +29,24 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
29
29
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
30
30
|
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
31
31
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
32
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
33
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
34
32
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
33
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
34
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
35
35
|
var Background__default = /*#__PURE__*/_interopDefaultLegacy(Background);
|
|
36
|
-
var
|
|
36
|
+
var CallToAction__default = /*#__PURE__*/_interopDefaultLegacy(CallToAction);
|
|
37
37
|
var ClosedCaptions__default = /*#__PURE__*/_interopDefaultLegacy(ClosedCaptions);
|
|
38
|
-
var
|
|
38
|
+
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
|
|
39
39
|
var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
|
|
40
|
+
var MediaControls__default = /*#__PURE__*/_interopDefaultLegacy(MediaControls);
|
|
40
41
|
var Video__default = /*#__PURE__*/_interopDefaultLegacy(Video);
|
|
41
|
-
var CallToAction__default = /*#__PURE__*/_interopDefaultLegacy(CallToAction);
|
|
42
42
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
43
43
|
|
|
44
|
-
var styles = {"container":"micromag-screen-video-container","content":"micromag-screen-video-content","empty":"micromag-screen-video-empty","emptyContainer":"micromag-screen-video-emptyContainer","fullscreen":"micromag-screen-video-fullscreen","image":"micromag-screen-video-image","placeholder":"micromag-screen-video-placeholder","video":"micromag-screen-video-video","disabled":"micromag-screen-video-disabled","hidden":"micromag-screen-video-hidden","mediaControls":"micromag-screen-video-mediaControls","videoContainer":"micromag-screen-video-videoContainer","bottomContent":"micromag-screen-video-bottomContent"};
|
|
44
|
+
var styles = {"container":"micromag-screen-video-container","content":"micromag-screen-video-content","empty":"micromag-screen-video-empty","emptyContainer":"micromag-screen-video-emptyContainer","fullscreen":"micromag-screen-video-fullscreen","image":"micromag-screen-video-image","placeholder":"micromag-screen-video-placeholder","video":"micromag-screen-video-video","disabled":"micromag-screen-video-disabled","hidden":"micromag-screen-video-hidden","mediaControls":"micromag-screen-video-mediaControls","visible":"micromag-screen-video-visible","videoContainer":"micromag-screen-video-videoContainer","bottomContent":"micromag-screen-video-bottomContent"};
|
|
45
45
|
|
|
46
46
|
var propTypes = {
|
|
47
47
|
layout: PropTypes__default["default"].oneOf(['middle', 'full']),
|
|
48
48
|
video: core.PropTypes.videoElement,
|
|
49
|
+
gotoNextScreenOnEnd: PropTypes__default["default"].bool,
|
|
49
50
|
background: core.PropTypes.backgroundElement,
|
|
50
51
|
callToAction: core.PropTypes.callToAction,
|
|
51
52
|
current: PropTypes__default["default"].bool,
|
|
@@ -58,6 +59,7 @@ var propTypes = {
|
|
|
58
59
|
var defaultProps = {
|
|
59
60
|
layout: 'middle',
|
|
60
61
|
video: null,
|
|
62
|
+
gotoNextScreenOnEnd: false,
|
|
61
63
|
background: null,
|
|
62
64
|
callToAction: null,
|
|
63
65
|
current: true,
|
|
@@ -69,10 +71,11 @@ var defaultProps = {
|
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
var VideoScreen = function VideoScreen(_ref) {
|
|
72
|
-
var
|
|
74
|
+
var _ref9;
|
|
73
75
|
|
|
74
76
|
var layout = _ref.layout,
|
|
75
77
|
video = _ref.video,
|
|
78
|
+
gotoNextScreenOnEnd = _ref.gotoNextScreenOnEnd,
|
|
76
79
|
background = _ref.background,
|
|
77
80
|
callToAction = _ref.callToAction,
|
|
78
81
|
current = _ref.current,
|
|
@@ -95,9 +98,13 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
95
98
|
isStatic = _useScreenRenderConte.isStatic,
|
|
96
99
|
isCapture = _useScreenRenderConte.isCapture;
|
|
97
100
|
|
|
101
|
+
var _useViewerNavigation = contexts.useViewerNavigation(),
|
|
102
|
+
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
103
|
+
|
|
98
104
|
var backgroundPlaying = current && (isView || isEdit);
|
|
99
105
|
var backgroundShouldLoad = current || active || !isView;
|
|
100
106
|
var videoShouldLoad = current || active || !isView;
|
|
107
|
+
var shouldGotoNextScreenOnEnd = gotoNextScreenOnEnd && isView && current;
|
|
101
108
|
var apiRef = React.useRef();
|
|
102
109
|
|
|
103
110
|
var _ref2 = apiRef.current || {},
|
|
@@ -113,27 +120,34 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
113
120
|
if (apiMediaRef !== null && getMediaRef !== null) {
|
|
114
121
|
getMediaRef(apiMediaRef.current);
|
|
115
122
|
}
|
|
116
|
-
}, [apiMediaRef, getMediaRef]);
|
|
123
|
+
}, [apiMediaRef, getMediaRef]);
|
|
124
|
+
var mouseMoveRef = React.useRef(null);
|
|
117
125
|
|
|
118
|
-
var _useState = React.useState(
|
|
126
|
+
var _useState = React.useState(false),
|
|
119
127
|
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
showMediaControls = _useState2[0],
|
|
129
|
+
setShowMediaControls = _useState2[1]; // Get api state updates from callback
|
|
130
|
+
|
|
122
131
|
|
|
123
132
|
var _useState3 = React.useState(null),
|
|
124
133
|
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
currentTime = _useState4[0],
|
|
135
|
+
setCurrentTime = _useState4[1];
|
|
127
136
|
|
|
128
|
-
var _useState5 = React.useState(
|
|
137
|
+
var _useState5 = React.useState(null),
|
|
129
138
|
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
duration = _useState6[0],
|
|
140
|
+
setDuration = _useState6[1];
|
|
132
141
|
|
|
133
142
|
var _useState7 = React.useState(false),
|
|
134
143
|
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
playing = _useState8[0],
|
|
145
|
+
setPlaying = _useState8[1];
|
|
146
|
+
|
|
147
|
+
var _useState9 = React.useState(false),
|
|
148
|
+
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
149
|
+
muted = _useState10[0],
|
|
150
|
+
setMuted = _useState10[1];
|
|
137
151
|
|
|
138
152
|
var onTimeUpdate = React.useCallback(function (time) {
|
|
139
153
|
setCurrentTime(time);
|
|
@@ -170,23 +184,41 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
170
184
|
|
|
171
185
|
toggleMute();
|
|
172
186
|
}, [muted, toggleMute]);
|
|
187
|
+
var onEnded = React.useCallback(function () {
|
|
188
|
+
if (shouldGotoNextScreenOnEnd) {
|
|
189
|
+
gotoNextScreen();
|
|
190
|
+
}
|
|
191
|
+
}, [shouldGotoNextScreenOnEnd, seek, gotoNextScreen]);
|
|
173
192
|
React.useEffect(function () {
|
|
174
193
|
if (!current && playing) {
|
|
175
194
|
pause();
|
|
176
195
|
}
|
|
177
|
-
}, [playing, current]);
|
|
196
|
+
}, [playing, current]);
|
|
197
|
+
var onMouseMove = React.useCallback(function () {
|
|
198
|
+
setShowMediaControls(true);
|
|
199
|
+
|
|
200
|
+
if (mouseMoveRef.current !== null) {
|
|
201
|
+
clearTimeout(mouseMoveRef.current);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
mouseMoveRef.current = setTimeout(function () {
|
|
205
|
+
setShowMediaControls(false);
|
|
206
|
+
mouseMoveRef.current = null;
|
|
207
|
+
}, 1800);
|
|
208
|
+
}, [setShowMediaControls]); // ------------------------------------
|
|
178
209
|
|
|
179
210
|
var longPressBind = hooks.useLongPress({
|
|
180
|
-
onLongPress: togglePlay
|
|
211
|
+
onLongPress: togglePlay,
|
|
212
|
+
onClick: onMouseMove
|
|
181
213
|
});
|
|
182
214
|
var fullscreen = layout === 'full';
|
|
183
215
|
var hasCallToAction = callToAction !== null && callToAction.active === true;
|
|
184
216
|
var hasVideo = video !== null;
|
|
185
217
|
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
ready =
|
|
189
|
-
setReady =
|
|
218
|
+
var _useState11 = React.useState(hasVideo),
|
|
219
|
+
_useState12 = _slicedToArray__default["default"](_useState11, 2),
|
|
220
|
+
ready = _useState12[0],
|
|
221
|
+
setReady = _useState12[1]; // useState(!hasVideo);
|
|
190
222
|
|
|
191
223
|
|
|
192
224
|
var transitionPlaying = current && ready;
|
|
@@ -202,7 +234,9 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
202
234
|
_ref5$withSeekBar = _ref5.withSeekBar,
|
|
203
235
|
withSeekBar = _ref5$withSeekBar === void 0 ? false : _ref5$withSeekBar,
|
|
204
236
|
_ref5$withPlayPause = _ref5.withPlayPause,
|
|
205
|
-
withPlayPause = _ref5$withPlayPause === void 0 ? false : _ref5$withPlayPause
|
|
237
|
+
withPlayPause = _ref5$withPlayPause === void 0 ? false : _ref5$withPlayPause,
|
|
238
|
+
_ref5$withTime = _ref5.withTime,
|
|
239
|
+
withTime = _ref5$withTime === void 0 ? false : _ref5$withTime;
|
|
206
240
|
|
|
207
241
|
var finalVideo = React.useMemo(function () {
|
|
208
242
|
return hasVideo ? _objectSpread__default["default"](_objectSpread__default["default"]({}, video), {}, {
|
|
@@ -299,6 +333,7 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
299
333
|
onProgressStep: onProgressStep,
|
|
300
334
|
onDurationChanged: onDurationChanged,
|
|
301
335
|
onSeeked: onSeeked,
|
|
336
|
+
onEnded: onEnded,
|
|
302
337
|
onVolumeChanged: onVolumeChanged,
|
|
303
338
|
focusable: current && isView,
|
|
304
339
|
preload: videoShouldLoad ? 'auto' : 'metadata' // onPosterLoaded={onPosterLoaded}
|
|
@@ -315,9 +350,10 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
315
350
|
media: closedCaptions,
|
|
316
351
|
currentTime: currentTime
|
|
317
352
|
}) : null, hasVideoUrl ? /*#__PURE__*/React__default["default"].createElement(MediaControls__default["default"], {
|
|
318
|
-
className: styles.mediaControls,
|
|
353
|
+
className: classNames__default["default"]([styles.mediaControls, _defineProperty__default["default"]({}, styles.visible, !autoPlay && !playing || muted || showMediaControls)]),
|
|
319
354
|
withSeekBar: withSeekBar,
|
|
320
355
|
withPlayPause: withPlayPause,
|
|
356
|
+
withTime: withTime,
|
|
321
357
|
playing: playing,
|
|
322
358
|
muted: muted,
|
|
323
359
|
currentTime: currentTime,
|
|
@@ -336,11 +372,13 @@ var VideoScreen = function VideoScreen(_ref) {
|
|
|
336
372
|
focusable: current && isView
|
|
337
373
|
})) : null)) : null];
|
|
338
374
|
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
339
|
-
className: classNames__default["default"]([styles.container, (
|
|
375
|
+
className: classNames__default["default"]([styles.container, (_ref9 = {}, _defineProperty__default["default"](_ref9, className, className !== null), _defineProperty__default["default"](_ref9, styles.fullscreen, fullscreen), _ref9)]),
|
|
340
376
|
"data-screen-ready": isStatic || isCapture
|
|
341
377
|
/* && posterReady */
|
|
342
378
|
|| ready
|
|
343
|
-
}, longPressBind
|
|
379
|
+
}, longPressBind, {
|
|
380
|
+
onMouseMove: onMouseMove
|
|
381
|
+
}), !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
|
|
344
382
|
background: background,
|
|
345
383
|
width: width,
|
|
346
384
|
height: height,
|
|
@@ -435,6 +473,17 @@ var definition = {
|
|
|
435
473
|
"value": "Video"
|
|
436
474
|
}]
|
|
437
475
|
})
|
|
476
|
+
}, {
|
|
477
|
+
name: 'gotoNextScreenOnEnd',
|
|
478
|
+
type: 'toggle',
|
|
479
|
+
defaultValue: false,
|
|
480
|
+
label: reactIntl.defineMessage({
|
|
481
|
+
id: "n8zmLY",
|
|
482
|
+
defaultMessage: [{
|
|
483
|
+
"type": 0,
|
|
484
|
+
"value": "Go to next screen on end"
|
|
485
|
+
}]
|
|
486
|
+
})
|
|
438
487
|
}, {
|
|
439
488
|
name: 'background',
|
|
440
489
|
type: 'background',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-video",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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.15",
|
|
53
|
-
"@micromag/core": "^0.
|
|
54
|
-
"@micromag/element-background": "^0.
|
|
55
|
-
"@micromag/element-call-to-action": "^0.
|
|
56
|
-
"@micromag/element-closed-captions": "^0.
|
|
57
|
-
"@micromag/element-container": "^0.
|
|
58
|
-
"@micromag/element-image": "^0.
|
|
59
|
-
"@micromag/element-media-controls": "^0.
|
|
60
|
-
"@micromag/element-video": "^0.
|
|
61
|
-
"@micromag/transforms": "^0.
|
|
53
|
+
"@micromag/core": "^0.3.1",
|
|
54
|
+
"@micromag/element-background": "^0.3.1",
|
|
55
|
+
"@micromag/element-call-to-action": "^0.3.1",
|
|
56
|
+
"@micromag/element-closed-captions": "^0.3.1",
|
|
57
|
+
"@micromag/element-container": "^0.3.1",
|
|
58
|
+
"@micromag/element-image": "^0.3.1",
|
|
59
|
+
"@micromag/element-media-controls": "^0.3.1",
|
|
60
|
+
"@micromag/element-video": "^0.3.1",
|
|
61
|
+
"@micromag/transforms": "^0.3.1",
|
|
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": "
|
|
71
|
+
"gitHead": "7a9abcecc77a97ec7b698743fd38378ac159a9c4"
|
|
72
72
|
}
|