@micromag/element-video 0.3.318 → 0.3.322
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 +27 -8
- package/lib/index.js +27 -8
- package/package.json +5 -5
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.micromag-element-video-container.micromag-element-video-withSize .micromag-element-video-video{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-element-video-container{position:relative}.micromag-element-video-container .micromag-element-video-video{display:block;width:100%}
|
|
1
|
+
.micromag-element-video-container .micromag-element-video-spinner,.micromag-element-video-container.micromag-element-video-withSize .micromag-element-video-video{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-element-video-container{position:relative}.micromag-element-video-container .micromag-element-video-video{display:block;width:100%}.micromag-element-video-container .micromag-element-video-spinner{height:32px;left:50%;margin-left:-16px;margin-top:-16px;top:50%;width:32px}
|
package/es/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import isFunction from 'lodash/isFunction';
|
|
6
6
|
import PropTypes$1 from 'prop-types';
|
|
7
|
-
import React, { useMemo, useRef, useEffect, useCallback
|
|
7
|
+
import React, { useMemo, useRef, useState, useEffect, useCallback } from 'react';
|
|
8
8
|
import { PropTypes } from '@micromag/core';
|
|
9
|
+
import { Spinner } from '@micromag/core/components';
|
|
9
10
|
import { useMediaThumbnail, useMediaCurrentTime, useMediaDuration, useMediaReady, useProgressSteps } from '@micromag/core/hooks';
|
|
10
11
|
import { getMediaFilesAsArray, getVideoSupportedMimes } from '@micromag/core/utils';
|
|
11
12
|
|
|
12
|
-
var styles = {"container":"micromag-element-video-container","withSize":"micromag-element-video-withSize","video":"micromag-element-video-video"};
|
|
13
|
+
var styles = {"container":"micromag-element-video-container","withSize":"micromag-element-video-withSize","video":"micromag-element-video-video","spinner":"micromag-element-video-spinner"};
|
|
13
14
|
|
|
14
15
|
var propTypes = {
|
|
15
16
|
media: PropTypes.videoMedia,
|
|
@@ -126,9 +127,25 @@ var Video = function Video(_ref) {
|
|
|
126
127
|
var duration = useMediaDuration(_ref9.current, {
|
|
127
128
|
id: mediaUrl
|
|
128
129
|
});
|
|
130
|
+
var _useState = useState(false),
|
|
131
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
132
|
+
showLoading = _useState2[0],
|
|
133
|
+
setShowLoading = _useState2[1];
|
|
129
134
|
var ready = useMediaReady(_ref9.current, {
|
|
130
135
|
id: mediaUrl
|
|
131
136
|
});
|
|
137
|
+
useEffect(function () {
|
|
138
|
+
var id = null;
|
|
139
|
+
setShowLoading(false);
|
|
140
|
+
if (mediaUrl) {
|
|
141
|
+
id = setTimeout(function () {
|
|
142
|
+
setShowLoading(true);
|
|
143
|
+
}, 1000);
|
|
144
|
+
}
|
|
145
|
+
return function () {
|
|
146
|
+
clearTimeout(id);
|
|
147
|
+
};
|
|
148
|
+
}, [mediaUrl]);
|
|
132
149
|
var sourceFiles = useMemo(function () {
|
|
133
150
|
if (filesArray.length === 0) {
|
|
134
151
|
return null;
|
|
@@ -184,10 +201,10 @@ var Video = function Video(_ref) {
|
|
|
184
201
|
}, [customOnVolumeChange]);
|
|
185
202
|
|
|
186
203
|
// Manage suspend
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
isSuspended =
|
|
190
|
-
setIsSuspended =
|
|
204
|
+
var _useState3 = useState(false),
|
|
205
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
206
|
+
isSuspended = _useState4[0],
|
|
207
|
+
setIsSuspended = _useState4[1];
|
|
191
208
|
var onPlay = useCallback(function (e) {
|
|
192
209
|
if (isSuspended) {
|
|
193
210
|
setIsSuspended(false);
|
|
@@ -284,7 +301,9 @@ var Video = function Video(_ref) {
|
|
|
284
301
|
src: sourceUrl !== null ? "".concat(sourceUrl, "#t=0.1") : null,
|
|
285
302
|
type: sourceMime
|
|
286
303
|
});
|
|
287
|
-
})) : null
|
|
304
|
+
})) : null, !isImageWithoutSourceFile && !ready && showLoading ? /*#__PURE__*/React.createElement(Spinner, {
|
|
305
|
+
className: styles.spinner
|
|
306
|
+
}) : null);
|
|
288
307
|
};
|
|
289
308
|
Video.propTypes = propTypes;
|
|
290
309
|
Video.defaultProps = defaultProps;
|
package/lib/index.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
4
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
5
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
6
6
|
var classNames = require('classnames');
|
|
7
7
|
var isFunction = require('lodash/isFunction');
|
|
8
8
|
var PropTypes = require('prop-types');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var core = require('@micromag/core');
|
|
11
|
+
var components = require('@micromag/core/components');
|
|
11
12
|
var hooks = require('@micromag/core/hooks');
|
|
12
13
|
var utils = require('@micromag/core/utils');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
16
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
17
17
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
18
18
|
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
19
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
19
20
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
20
21
|
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);
|
|
21
22
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
22
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
24
|
|
|
24
|
-
var styles = {"container":"micromag-element-video-container","withSize":"micromag-element-video-withSize","video":"micromag-element-video-video"};
|
|
25
|
+
var styles = {"container":"micromag-element-video-container","withSize":"micromag-element-video-withSize","video":"micromag-element-video-video","spinner":"micromag-element-video-spinner"};
|
|
25
26
|
|
|
26
27
|
var propTypes = {
|
|
27
28
|
media: core.PropTypes.videoMedia,
|
|
@@ -138,9 +139,25 @@ var Video = function Video(_ref) {
|
|
|
138
139
|
var duration = hooks.useMediaDuration(_ref9.current, {
|
|
139
140
|
id: mediaUrl
|
|
140
141
|
});
|
|
142
|
+
var _useState = React.useState(false),
|
|
143
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
144
|
+
showLoading = _useState2[0],
|
|
145
|
+
setShowLoading = _useState2[1];
|
|
141
146
|
var ready = hooks.useMediaReady(_ref9.current, {
|
|
142
147
|
id: mediaUrl
|
|
143
148
|
});
|
|
149
|
+
React.useEffect(function () {
|
|
150
|
+
var id = null;
|
|
151
|
+
setShowLoading(false);
|
|
152
|
+
if (mediaUrl) {
|
|
153
|
+
id = setTimeout(function () {
|
|
154
|
+
setShowLoading(true);
|
|
155
|
+
}, 1000);
|
|
156
|
+
}
|
|
157
|
+
return function () {
|
|
158
|
+
clearTimeout(id);
|
|
159
|
+
};
|
|
160
|
+
}, [mediaUrl]);
|
|
144
161
|
var sourceFiles = React.useMemo(function () {
|
|
145
162
|
if (filesArray.length === 0) {
|
|
146
163
|
return null;
|
|
@@ -196,10 +213,10 @@ var Video = function Video(_ref) {
|
|
|
196
213
|
}, [customOnVolumeChange]);
|
|
197
214
|
|
|
198
215
|
// Manage suspend
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
isSuspended =
|
|
202
|
-
setIsSuspended =
|
|
216
|
+
var _useState3 = React.useState(false),
|
|
217
|
+
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
218
|
+
isSuspended = _useState4[0],
|
|
219
|
+
setIsSuspended = _useState4[1];
|
|
203
220
|
var onPlay = React.useCallback(function (e) {
|
|
204
221
|
if (isSuspended) {
|
|
205
222
|
setIsSuspended(false);
|
|
@@ -296,7 +313,9 @@ var Video = function Video(_ref) {
|
|
|
296
313
|
src: sourceUrl !== null ? "".concat(sourceUrl, "#t=0.1") : null,
|
|
297
314
|
type: sourceMime
|
|
298
315
|
});
|
|
299
|
-
})) : null
|
|
316
|
+
})) : null, !isImageWithoutSourceFile && !ready && showLoading ? /*#__PURE__*/React__default["default"].createElement(components.Spinner, {
|
|
317
|
+
className: styles.spinner
|
|
318
|
+
}) : null);
|
|
300
319
|
};
|
|
301
320
|
Video.propTypes = propTypes;
|
|
302
321
|
Video.defaultProps = defaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-video",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.322",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
53
53
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
54
54
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
55
|
-
"@micromag/core": "^0.3.
|
|
56
|
-
"@micromag/element-closed-captions": "^0.3.
|
|
57
|
-
"@micromag/element-media-controls": "^0.3.
|
|
55
|
+
"@micromag/core": "^0.3.322",
|
|
56
|
+
"@micromag/element-closed-captions": "^0.3.322",
|
|
57
|
+
"@micromag/element-media-controls": "^0.3.322",
|
|
58
58
|
"classnames": "^2.2.6",
|
|
59
59
|
"lodash": "^4.17.21",
|
|
60
60
|
"prop-types": "^15.7.2",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "2dfe09ad5a9ac720e4bfbffcb6371fc31c24fa9f"
|
|
68
68
|
}
|