react-modern-audio-player 0.0.3 → 1.0.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/LICENSE +21 -0
- package/README.md +290 -46
- package/dist/index.cjs +54 -54
- package/dist/index.css +1 -1
- package/dist/index.es.js +143 -130
- package/dist/types/components/AudioPlayer/Context/StateContext/placement.d.ts +1 -2
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/PrevNnextBtn.d.ts +1 -0
- package/dist/types/components/Grid/Item.d.ts +7 -2
- package/dist/types/utils/generateGridTemplateValues.d.ts +1 -1
- package/package.json +2 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 LYH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,53 +1,297 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="20%" src="https://user-images.githubusercontent.com/70849655/180391190-2b268d23-c9f3-4e95-9fce-090897842c04.png" alt="rm-audio-player" />
|
|
3
|
+
<h1 align="center">React Modern Audio Player</h1>
|
|
4
|
+
</p>
|
|
2
5
|
|
|
3
|
-
## Override Style
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/react-modern-audio-player">
|
|
9
|
+
<img src="https://img.shields.io/npm/v/react-modern-audio-player" alt="Version">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/react-modern-audio-player">
|
|
12
|
+
<img src="https://img.shields.io/npm/dt/react-modern-audio-player" alt="Download">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://bundlephobia.com/package/react-modern-audio-player@0.0.3">
|
|
15
|
+
<img src="https://badgen.net/bundlephobia/minzip/react-modern-audio-player" alt="Download">
|
|
16
|
+
</a>
|
|
17
|
+
</p>
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
# ****Flexible and Customizable UI****
|
|
20
|
+
## This can offer waveform by `wavesurfer.js`
|
|
21
|
+
<img width="100%" src="https://user-images.githubusercontent.com/70849655/180435472-f043dbb4-54df-43e0-bc5c-67492510e817.png" alt="">
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- sortable-play-list-content-container (root)
|
|
16
|
-
- sortable-list
|
|
17
|
-
- list-item-root
|
|
18
|
-
- list-item-container
|
|
19
|
-
- album-cover-wrapper
|
|
20
|
-
- album-info-wrapper
|
|
21
|
-
- list-item-root dragstart
|
|
22
|
-
- list-item-root dragover
|
|
23
|
+
## This can offer various UI and you can also customize each component position
|
|
24
|
+
> Full View
|
|
25
|
+
> <img width="100%" src="https://user-images.githubusercontent.com/70849655/180435489-263fae23-f066-4a37-a524-58918eb40b0c.png" alt="">
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
> Position Change
|
|
28
|
+
> <img width="110%" src="https://user-images.githubusercontent.com/70849655/180435493-2c2e08c5-b67b-4ab7-aded-5a0403d42050.png" alt="">
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
> Particular View
|
|
32
|
+
> </br>
|
|
33
|
+
><img width="50%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435497-0f839cd1-e1fd-400f-a013-82ba441ca79b.png" alt="">
|
|
34
|
+
><img width="20%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435479-4f056620-f850-4d21-ab23-24efc4300d68.png" alt="">
|
|
35
|
+
> </br>
|
|
36
|
+
><img width="20%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435484-3331b7cb-1555-4ffb-a36c-a5343f72c8c3.png" alt="">
|
|
37
|
+
> <img width="50%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435486-2402ba80-7121-410c-9a06-9a737be72ec2.png" alt="">
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ****Installation****
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
npm install --save react-modern-audio-player
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
# ****Quick Start****
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import AudioPlayer from 'react-modern-audio-player';
|
|
50
|
+
|
|
51
|
+
const playList = [
|
|
52
|
+
{
|
|
53
|
+
name: 'name',
|
|
54
|
+
writer: 'write',
|
|
55
|
+
img: 'image.jpg',
|
|
56
|
+
src: 'audio.mp3',
|
|
57
|
+
id: 1,
|
|
58
|
+
index: 0,
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
function Player (){
|
|
62
|
+
return (
|
|
63
|
+
<AudioPlayer playList={playList} />
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
# Props
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
interface AudioPlayerProps {
|
|
72
|
+
playList: PlayList;
|
|
73
|
+
audioInitialState?: AudioInitialState;
|
|
74
|
+
activeUI?: ActiveUI;
|
|
75
|
+
customIcons?: CustomIcons;
|
|
76
|
+
coverImgsCss?: CoverImgsCss;
|
|
77
|
+
placement?: {
|
|
78
|
+
player?: PlayerPlacement;
|
|
79
|
+
playList?: PlayListPlacement;
|
|
80
|
+
interface?: InterfacePlacement;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Prop | Type | Default
|
|
86
|
+
--- | --- | ---
|
|
87
|
+
`playList` | [PlayList](#playlist) | [ ]
|
|
88
|
+
`audioInitialState` | [AudioInitialState](#audioinitialstate) | isPlaying: false </br>repeatType: "ALL" </br>volume: 1
|
|
89
|
+
`activeUI` | [ActiveUI](#activeui) | playButton : true
|
|
90
|
+
`customIcons` | [CustomIcons](#customicons) | undefined
|
|
91
|
+
`coverImgsCss` | [CoverImgsCss](#coverimgscss) | undefined
|
|
92
|
+
`placement` | [Placement](#placement) | playListPlacement : "bottom" </br>interfacePlacement :[DefaultInterfacePlacement](#default-interface-placement)
|
|
93
|
+
|
|
94
|
+
## PlayList
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
type PlayList = Array<AudioData>;
|
|
98
|
+
type AudioData = {
|
|
99
|
+
src: string;
|
|
100
|
+
id: number;
|
|
101
|
+
index: number;
|
|
102
|
+
name?: string | ReactNode;
|
|
103
|
+
writer?: string | ReactNode;
|
|
104
|
+
img?: string;
|
|
105
|
+
description?: string | ReactNode;
|
|
106
|
+
customTrackInfo?: string | ReactNode;
|
|
107
|
+
};
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## audioInitialState
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
type AudioInitialState = Omit<
|
|
114
|
+
React.AudioHTMLAttributes<HTMLAudioElement>,
|
|
115
|
+
"autoPlay"
|
|
116
|
+
> & {
|
|
117
|
+
isPlaying?: boolean;
|
|
118
|
+
repeatType?: RepeatType;
|
|
119
|
+
volume?: number;
|
|
120
|
+
currentTime?: number;
|
|
121
|
+
duration?: number;
|
|
122
|
+
curPlayId: number;
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## activeUI
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
type ActiveUI = {
|
|
130
|
+
all: boolean;
|
|
131
|
+
playButton: boolean;
|
|
132
|
+
playList: PlayListUI;
|
|
133
|
+
prevNnext: boolean;
|
|
134
|
+
volume: boolean;
|
|
135
|
+
repeatType: boolean;
|
|
136
|
+
trackTime: TrackTimeUI;
|
|
137
|
+
trackInfo: boolean;
|
|
138
|
+
artwork: boolean;
|
|
139
|
+
progress: ProgressUI;
|
|
140
|
+
};
|
|
141
|
+
type TrackTimeUI = "separation-mode" | "unification-mode" | false;
|
|
142
|
+
type ProgressUI = "waveform" | "bar" | false;
|
|
143
|
+
type PlayListUI = "sortable" | "unSortable" | false;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## customIcons
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
type CustomIcons = {
|
|
150
|
+
play: ReactNode;
|
|
151
|
+
pause: ReactNode;
|
|
152
|
+
prev: ReactNode;
|
|
153
|
+
next: ReactNode;
|
|
154
|
+
repeatOne: ReactNode;
|
|
155
|
+
repeatAll: ReactNode;
|
|
156
|
+
repeatNone: ReactNode;
|
|
157
|
+
repeatShuffle: ReactNode;
|
|
158
|
+
volumeFull: ReactNode;
|
|
159
|
+
volumeHalf: ReactNode;
|
|
160
|
+
volumeMuted: ReactNode;
|
|
161
|
+
playList: ReactNode;
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## coverImgsCss
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
interface CoverImgsCss {
|
|
169
|
+
artwork?: React.CSSProperties;
|
|
170
|
+
listThumbnail?: React.CSSProperties;
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## placement
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
type PlayerPlacement =
|
|
178
|
+
| "bottom"
|
|
179
|
+
| "top"
|
|
180
|
+
| "bottom-left"
|
|
181
|
+
| "bottom-right"
|
|
182
|
+
| "top-left"
|
|
183
|
+
| "top-right";
|
|
184
|
+
|
|
185
|
+
type PlayListPlacement = "bottom" | "top";
|
|
186
|
+
|
|
187
|
+
type InterfacePlacement = {
|
|
188
|
+
templateArea: InterfaceGridTemplateArea;
|
|
189
|
+
itemCustomArea?: InterfaceGridItemArea;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>
|
|
193
|
+
type InterfacePlacementKey =
|
|
194
|
+
| Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime">
|
|
195
|
+
| "trackTimeCurrent"
|
|
196
|
+
| "trackTimeDuration";
|
|
197
|
+
type InterfacePlacementValue = "row1-1" | "row1-2" | "row1-3" | "row1-4" | ... more ... | "row9-9";
|
|
198
|
+
|
|
199
|
+
type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
|
|
200
|
+
/** example
|
|
201
|
+
* check grid item MDN
|
|
202
|
+
* progress : 2-4
|
|
203
|
+
* repeatBtn : row1-4 / 2 / row1-4 / 10
|
|
204
|
+
*/
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Default interface placement
|
|
208
|
+
```tsx
|
|
209
|
+
const defaultInterfacePlacement = {
|
|
210
|
+
templateArea: {
|
|
211
|
+
artwork: "row1-1",
|
|
212
|
+
trackInfo: "row1-2",
|
|
213
|
+
trackTimeCurrent: "row1-3",
|
|
214
|
+
trackTimeDuration: "row1-4",
|
|
215
|
+
progress: "row1-5",
|
|
216
|
+
repeatType: "row1-6",
|
|
217
|
+
volume: "row1-7",
|
|
218
|
+
playButton: "row1-8",
|
|
219
|
+
playList: "row1-9",
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
# Override Style
|
|
225
|
+
|
|
226
|
+
### Theme mode ( dark-mode )
|
|
227
|
+
|
|
228
|
+
> it apply dark-mode depending on `system-theme`
|
|
229
|
+
you can customize color-theme by `css-variable` of `react-spectrum` `theme-default`
|
|
230
|
+
>
|
|
231
|
+
|
|
232
|
+
## ID & Classnames
|
|
233
|
+
|
|
234
|
+
### root ID
|
|
235
|
+
|
|
236
|
+
- rm-audio-player
|
|
237
|
+
|
|
238
|
+
### root ClassName
|
|
239
|
+
|
|
240
|
+
- rm-audio-player-provider
|
|
27
241
|
|
|
28
242
|
### color variables
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
--rm-audio-player-volume-background: #ccc;
|
|
246
|
+
--rm-audio-player-volume-panel-background: #f2f2f2;
|
|
247
|
+
--rm-audio-player-volume-panel-border: #ccc;
|
|
248
|
+
--rm-audio-player-volume-thumb: #e5e5e5;
|
|
249
|
+
--rm-audio-player-volume-fill: rgba(0, 0, 0, 0.5);
|
|
250
|
+
--rm-audio-player-volume-track: #ababab;
|
|
251
|
+
--rm-audio-player-track-current-time: #0072F5;
|
|
252
|
+
--rm-audio-player-track-duration: #8c8c8c;
|
|
253
|
+
--rm-audio-player-progress-bar: #0072F5;
|
|
254
|
+
--rm-audio-player-progress-bar-background: #D1D1D1;
|
|
255
|
+
--rm-audio-player-waveform-cursor: var(--spectrum-alias-text-color);
|
|
256
|
+
--rm-audio-player-waveform-background: var(--rm-audio-player-progress-bar-background);
|
|
257
|
+
--rm-audio-player-waveform-bar: var(--rm-audio-player-progress-bar);
|
|
258
|
+
--rm-audio-player-sortable-list-button-active: #0072F5;
|
|
259
|
+
--rm-audio-player-selected-list-item-background: var(--spectrum-alias-border-color);
|
|
260
|
+
|
|
261
|
+
// ...spectrim theme palette and so on... //
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
# ****Example****
|
|
265
|
+
```tsx
|
|
266
|
+
function App() {
|
|
267
|
+
return (
|
|
268
|
+
<div>
|
|
269
|
+
<AudioPlayer
|
|
270
|
+
playList={playList}
|
|
271
|
+
audioInitialState={{
|
|
272
|
+
muted: true,
|
|
273
|
+
volume: 0.2,
|
|
274
|
+
curPlayId: 1,
|
|
275
|
+
}}
|
|
276
|
+
placement={{
|
|
277
|
+
interface: {
|
|
278
|
+
templateArea: {
|
|
279
|
+
trackTimeDuration: "row1-5",
|
|
280
|
+
progress: "row1-4",
|
|
281
|
+
playButton: "row1-6",
|
|
282
|
+
repeatType: "row1-7",
|
|
283
|
+
volume: "row1-8",
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
player: "bottom-left",
|
|
287
|
+
}}
|
|
288
|
+
activeUI={{
|
|
289
|
+
all: true,
|
|
290
|
+
trackTime: "separation-mode",
|
|
291
|
+
progress: "waveform",
|
|
292
|
+
}}
|
|
293
|
+
/>
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
```
|