react-modern-audio-player 1.2.5 → 1.4.0-rc.0
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/README.md +64 -2
- package/dist/index.es.js +4845 -4858
- package/dist/types/components/AudioPlayer/Audio/index.d.ts +4 -2
- package/dist/types/components/AudioPlayer/Audio/useAudio.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/StateContext/placement.d.ts +9 -7
- package/dist/types/components/AudioPlayer/Context/dispatchContext.d.ts +3 -3
- package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/useProgress.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/useWavesurfer.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Interface/CustomComponent/index.d.ts +7 -0
- package/dist/types/components/AudioPlayer/Interface/index.d.ts +6 -2
- package/dist/types/components/AudioPlayer/Player/index.d.ts +5 -4
- package/dist/types/components/AudioPlayer/Player/usePropsStateEffect.d.ts +1 -1
- package/dist/types/components/AudioPlayer/index.d.ts +9 -3
- package/dist/types/components/Drawer/Drawer.d.ts +1 -2
- package/dist/types/components/Dropdown/Dropdown.d.ts +1 -2
- package/dist/types/components/Grid/Item.d.ts +1 -1
- package/dist/types/components/Provider/AudioPlayerProvider.d.ts +2 -2
- package/dist/types/hooks/useGridTemplate.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/components/AudioPlayer/Audio/Basic.d.ts +0 -2
- package/dist/types/components/AudioPlayer/Audio/WaveSurfer.d.ts +0 -2
- package/dist/types/components/AudioPlayer/Audio/useBasicAudio.d.ts +0 -2
- package/dist/types/components/AudioPlayer/Audio/useWaveSurfer.d.ts +0 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/useBarProgress.d.ts +0 -2
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ function Player (){
|
|
|
75
75
|
interface AudioPlayerProps {
|
|
76
76
|
playList: PlayList;
|
|
77
77
|
audioInitialState?: AudioInitialState;
|
|
78
|
+
audioRef?: React.MutableRefObject<HTMLAudioElement>;
|
|
78
79
|
activeUI?: ActiveUI;
|
|
79
80
|
customIcons?: CustomIcons;
|
|
80
81
|
coverImgsCss?: CoverImgsCss;
|
|
@@ -194,15 +195,21 @@ type PlayListPlacement = "bottom" | "top";
|
|
|
194
195
|
|
|
195
196
|
type InterfacePlacement = {
|
|
196
197
|
templateArea?: InterfaceGridTemplateArea;
|
|
198
|
+
customComponentsArea?: InterfaceGridCustomComponentsArea<TMaxLength>;
|
|
197
199
|
itemCustomArea?: InterfaceGridItemArea;
|
|
198
200
|
};
|
|
199
201
|
|
|
200
|
-
type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>
|
|
201
202
|
type InterfacePlacementKey =
|
|
202
203
|
| Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime">
|
|
203
204
|
| "trackTimeCurrent"
|
|
204
205
|
| "trackTimeDuration";
|
|
205
|
-
|
|
206
|
+
|
|
207
|
+
type InterfacePlacementValue = "row1-1" | "row1-2" | "row1-3" | "row1-4" | ... more ... | "row9-9"
|
|
208
|
+
/** if you apply custom components, values must be "row1-1" ~ any more */
|
|
209
|
+
|
|
210
|
+
type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>;
|
|
211
|
+
|
|
212
|
+
type InterfaceGridCustomComponentsArea = Record<componentId,InterfacePlacementValue>;
|
|
206
213
|
|
|
207
214
|
type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
|
|
208
215
|
/** example
|
|
@@ -279,6 +286,61 @@ const defaultInterfacePlacement = {
|
|
|
279
286
|
|
|
280
287
|
// ...spectrum theme palette and so on... //
|
|
281
288
|
```
|
|
289
|
+
# Custom Component
|
|
290
|
+
> you can apply custom component to `AudioPlayer` by `CustomComponent`
|
|
291
|
+
> </br>
|
|
292
|
+
> you can also set `viewProps` to `CustomComponent`
|
|
293
|
+
> </br>
|
|
294
|
+
> (https://react-spectrum.adobe.com/react-spectrum/View.html#props)
|
|
295
|
+
|
|
296
|
+
``` tsx
|
|
297
|
+
const activeUI: ActiveUI = {
|
|
298
|
+
all: true,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const placement = {
|
|
302
|
+
interface: {
|
|
303
|
+
customComponentsArea: {
|
|
304
|
+
playerCustomComponent: "row1-10",
|
|
305
|
+
},
|
|
306
|
+
} as InterfacePlacement<11>,
|
|
307
|
+
/**
|
|
308
|
+
* you should set generic value of `InterfacePlacement` as interfaces max length for auto-complete aria type such as "row-1-10"
|
|
309
|
+
* generic value must plus 1 than interfaces length because of 0 index
|
|
310
|
+
*/
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/** you can get audioPlayerState by props */
|
|
314
|
+
const CustomComponent = ({
|
|
315
|
+
audioPlayerState,
|
|
316
|
+
}: {
|
|
317
|
+
audioPlayerState?: AudioPlayerStateContext;
|
|
318
|
+
}) => {
|
|
319
|
+
const audioEl = audioPlayerState?.elementRefs?.audioEl;
|
|
320
|
+
const handOverTime = () => {
|
|
321
|
+
if (audioEl) {
|
|
322
|
+
audioEl.currentTime += 30;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
return (
|
|
326
|
+
<>
|
|
327
|
+
<button onClick={handOverTime}>+30</button>
|
|
328
|
+
</>
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
<AudioPlayer
|
|
333
|
+
playList={playList}
|
|
334
|
+
placement={placement}
|
|
335
|
+
activeUI={activeUI}
|
|
336
|
+
>
|
|
337
|
+
<AudioPlayer.CustomComponent id="playerCustomComponent">
|
|
338
|
+
<CustomComponent />
|
|
339
|
+
</AudioPlayer.CustomComponent>
|
|
340
|
+
</AudioPlayer>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
|
|
282
344
|
|
|
283
345
|
# ****Example****
|
|
284
346
|
```tsx
|