@micromag/element-audio 0.4.49 → 0.4.51
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/es/index.js +98 -93
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
1
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
5
|
import classNames from 'classnames';
|
|
5
6
|
import isFunction from 'lodash/isFunction';
|
|
6
7
|
import isNumber from 'lodash/isNumber';
|
|
7
|
-
import
|
|
8
|
+
import { useState, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
8
9
|
import { useDimensionObserver, useMediaCurrentTime, useMediaReady, useMediaDuration, useMediaLoad, useProgressSteps, useDevicePixelRatio } from '@micromag/core/hooks';
|
|
9
10
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
10
11
|
import { useGesture } from '@use-gesture/react';
|
|
11
12
|
import { useIntl } from 'react-intl';
|
|
13
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
14
|
import { useSpringRef, useSpring } from '@react-spring/core';
|
|
13
15
|
import { animated } from '@react-spring/web';
|
|
14
16
|
import { getContrastingColor } from '@micromag/core/utils';
|
|
@@ -112,52 +114,53 @@ function AudioBars(_ref) {
|
|
|
112
114
|
filterTaps: true
|
|
113
115
|
}
|
|
114
116
|
});
|
|
115
|
-
return /*#__PURE__*/
|
|
117
|
+
return /*#__PURE__*/jsxs("div", {
|
|
116
118
|
className: classNames([styles$2.container, className]),
|
|
117
|
-
ref: elRef
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
119
|
+
ref: elRef,
|
|
120
|
+
children: [/*#__PURE__*/jsx("svg", {
|
|
121
|
+
version: "1.1",
|
|
122
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
123
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
124
|
+
x: "0",
|
|
125
|
+
y: "0",
|
|
126
|
+
width: "".concat(elWidth, "px"),
|
|
127
|
+
height: "".concat(elHeight, "px"),
|
|
128
|
+
viewBox: "0 0 ".concat(elWidth, " ").concat(elHeight),
|
|
129
|
+
className: className,
|
|
130
|
+
xmlSpace: "preserve",
|
|
131
|
+
children: items.map(function (size, i) {
|
|
132
|
+
return /*#__PURE__*/jsx("rect", {
|
|
133
|
+
width: barWidth,
|
|
134
|
+
height: size,
|
|
135
|
+
x: i * barSize,
|
|
136
|
+
y: elHeight / 2 - size / 2,
|
|
137
|
+
fill: (currentSeek || current) > i * barSize ? 'white' : 'gray',
|
|
138
|
+
stroke: "black",
|
|
139
|
+
strokeWidth: "0px",
|
|
140
|
+
strokeLinejoin: "round",
|
|
141
|
+
strokeLinecap: "round"
|
|
142
|
+
}, "bar-".concat(i + 1));
|
|
143
|
+
})
|
|
144
|
+
}), /*#__PURE__*/jsx("button", _objectSpread(_objectSpread({}, bind()), {}, {
|
|
145
|
+
onClick: onClick,
|
|
146
|
+
type: "button",
|
|
147
|
+
className: styles$2.seekButton,
|
|
148
|
+
title: intl.formatMessage({
|
|
149
|
+
id: "G1Gyjn",
|
|
150
|
+
defaultMessage: [{
|
|
151
|
+
"type": 0,
|
|
152
|
+
"value": "Seek"
|
|
153
|
+
}]
|
|
154
|
+
}),
|
|
155
|
+
"aria-label": intl.formatMessage({
|
|
156
|
+
id: "G1Gyjn",
|
|
157
|
+
defaultMessage: [{
|
|
158
|
+
"type": 0,
|
|
159
|
+
"value": "Seek"
|
|
160
|
+
}]
|
|
161
|
+
})
|
|
162
|
+
}))]
|
|
163
|
+
});
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
var styles$1 = {"container":"micromag-element-audio-container","wave":"micromag-element-audio-wave","withAutoHeight":"micromag-element-audio-withAutoHeight"};
|
|
@@ -319,45 +322,45 @@ function Audio(_ref) {
|
|
|
319
322
|
onStep: onProgressStep
|
|
320
323
|
});
|
|
321
324
|
var progress = currentTime !== null && duration > 0 ? currentTime / duration : 0;
|
|
322
|
-
return /*#__PURE__*/
|
|
323
|
-
className: classNames([styles$1.container, className])
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
mediaRef
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
})
|
|
325
|
+
return /*#__PURE__*/jsxs("div", {
|
|
326
|
+
className: classNames([styles$1.container, className]),
|
|
327
|
+
children: [/*#__PURE__*/jsx("audio", {
|
|
328
|
+
ref: function ref(newRef) {
|
|
329
|
+
_ref7.current = newRef;
|
|
330
|
+
if (mediaRef !== null && isFunction(mediaRef)) {
|
|
331
|
+
mediaRef(newRef);
|
|
332
|
+
} else if (mediaRef !== null) {
|
|
333
|
+
mediaRef.current = newRef;
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
src: srcUrl,
|
|
337
|
+
autoPlay: autoPlay && !paused,
|
|
338
|
+
muted: muted,
|
|
339
|
+
loop: loop,
|
|
340
|
+
crossOrigin: "anonymous",
|
|
341
|
+
preload: preload,
|
|
342
|
+
onPlay: onPlay,
|
|
343
|
+
onPause: onPause,
|
|
344
|
+
onEnded: onEnded,
|
|
345
|
+
onSeeked: onSeeked,
|
|
346
|
+
onTimeUpdate: onTimeUpdate,
|
|
347
|
+
onVolumeChange: onVolumeChange
|
|
348
|
+
}, srcUrl), withWave ? /*#__PURE__*/jsx(AudioBars, {
|
|
349
|
+
className: classNames([styles$1.wave, _defineProperty({}, styles$1.withAutoHeight, autoWaveHeight)]),
|
|
350
|
+
progress: progress
|
|
351
|
+
// {...waveProps}
|
|
352
|
+
,
|
|
353
|
+
duration: duration,
|
|
354
|
+
playing: !paused,
|
|
355
|
+
seek: !withoutSeek ? onWaveSeek : null,
|
|
356
|
+
play: onWavePlay
|
|
357
|
+
}) : null]
|
|
358
|
+
});
|
|
356
359
|
}
|
|
357
360
|
var Audio_default = (function (_ref9) {
|
|
358
361
|
var ref = _ref9.ref,
|
|
359
362
|
props = _objectWithoutProperties(_ref9, _excluded);
|
|
360
|
-
return /*#__PURE__*/
|
|
363
|
+
return /*#__PURE__*/jsx(Audio, _objectSpread({
|
|
361
364
|
mediaRef: ref
|
|
362
365
|
}, props));
|
|
363
366
|
});
|
|
@@ -554,20 +557,22 @@ function AudioWave(_ref) {
|
|
|
554
557
|
filterTaps: true
|
|
555
558
|
}
|
|
556
559
|
});
|
|
557
|
-
return /*#__PURE__*/
|
|
560
|
+
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
558
561
|
className: classNames([styles.container, className]),
|
|
559
562
|
ref: elRef
|
|
560
|
-
}, bind()),
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
563
|
+
}, bind()), {}, {
|
|
564
|
+
children: [/*#__PURE__*/jsx("canvas", {
|
|
565
|
+
ref: canvasBackgroundRef,
|
|
566
|
+
className: styles.canvasBackground
|
|
567
|
+
}), /*#__PURE__*/jsx(animated.canvas, {
|
|
568
|
+
ref: canvasProgressRef,
|
|
569
|
+
className: styles.canvasProgress,
|
|
570
|
+
style: {
|
|
571
|
+
clipPath: springProps.x.to(function (x) {
|
|
572
|
+
return "polygon(0 0, ".concat(x * 100, "% 0, ").concat(x * 100, "% 100%, 0 100%)");
|
|
573
|
+
})
|
|
574
|
+
}
|
|
575
|
+
})]
|
|
571
576
|
}));
|
|
572
577
|
}
|
|
573
578
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-audio",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@babel/runtime": "^7.28.6",
|
|
64
|
-
"@micromag/core": "^0.4.
|
|
65
|
-
"@micromag/element-closed-captions": "^0.4.
|
|
64
|
+
"@micromag/core": "^0.4.51",
|
|
65
|
+
"@micromag/element-closed-captions": "^0.4.51",
|
|
66
66
|
"@react-spring/core": "^10.0.3",
|
|
67
67
|
"@react-spring/web": "^10.0.3",
|
|
68
68
|
"@use-gesture/react": "^10.3.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"access": "public",
|
|
76
76
|
"registry": "https://registry.npmjs.org/"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "985a2370829c9ac8901ea97bf20bfc98ab158439"
|
|
79
79
|
}
|