react-modern-audio-player 0.0.2 → 1.0.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/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 ADDED
@@ -0,0 +1,300 @@
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>
5
+
6
+ <p align="center">
7
+ <a href="https://github.com/slash9494/react-modern-audio-player/blob/main/package/LICENSE">
8
+ <img src="https://img.shields.io/npm/l/react-modern-audio-player" alt="License">
9
+ </a>
10
+ <a href="https://www.npmjs.com/package/react-modern-audio-player">
11
+ <img src="https://img.shields.io/npm/v/react-modern-audio-player" alt="Version">
12
+ </a>
13
+ <a href="https://www.npmjs.com/package/react-modern-audio-player">
14
+ <img src="https://img.shields.io/npm/dt/react-modern-audio-player" alt="Download">
15
+ </a>
16
+ <a href="https://bundlephobia.com/package/react-modern-audio-player@0.0.3">
17
+ <img src="https://img.shields.io/bundlephobia/minzip/react-modern-audio-player" alt="BundleSize">
18
+ </a>
19
+ </p>
20
+
21
+ # ****Flexible and Customizable UI****
22
+ ## This can offer waveform by `wavesurfer.js`
23
+ <img width="100%" src="https://user-images.githubusercontent.com/70849655/180435472-f043dbb4-54df-43e0-bc5c-67492510e817.png" alt="">
24
+
25
+ ## This can offer various UI and you can also customize each component position
26
+ > Full View
27
+ > <img width="100%" src="https://user-images.githubusercontent.com/70849655/180435489-263fae23-f066-4a37-a524-58918eb40b0c.png" alt="">
28
+
29
+ > Position Change
30
+ > <img width="110%" src="https://user-images.githubusercontent.com/70849655/180435493-2c2e08c5-b67b-4ab7-aded-5a0403d42050.png" alt="">
31
+
32
+
33
+ > Particular View
34
+ > </br>
35
+ ><img width="50%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435497-0f839cd1-e1fd-400f-a013-82ba441ca79b.png" alt="">
36
+ ><img width="20%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435479-4f056620-f850-4d21-ab23-24efc4300d68.png" alt="">
37
+ > </br>
38
+ ><img width="20%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435484-3331b7cb-1555-4ffb-a36c-a5343f72c8c3.png" alt="">
39
+ > <img width="50%" margin='10px' src="https://user-images.githubusercontent.com/70849655/180435486-2402ba80-7121-410c-9a06-9a737be72ec2.png" alt="">
40
+
41
+
42
+ # ****Installation****
43
+
44
+ ```tsx
45
+ npm install --save react-modern-audio-player
46
+ ```
47
+
48
+ # ****Quick Start****
49
+
50
+ ```tsx
51
+ import AudioPlayer from 'react-modern-audio-player';
52
+
53
+ const playList = [
54
+ {
55
+ name: 'name',
56
+ writer: 'write',
57
+ img: 'image.jpg',
58
+ src: 'audio.mp3',
59
+ id: 1,
60
+ index: 0,
61
+ },
62
+ ]
63
+ function Player (){
64
+ return (
65
+ <AudioPlayer playList={playList} />
66
+ )
67
+ }
68
+ ```
69
+
70
+ # Props
71
+
72
+ ```tsx
73
+ interface AudioPlayerProps {
74
+ playList: PlayList;
75
+ audioInitialState?: AudioInitialState;
76
+ activeUI?: ActiveUI;
77
+ customIcons?: CustomIcons;
78
+ coverImgsCss?: CoverImgsCss;
79
+ placement?: {
80
+ player?: PlayerPlacement;
81
+ playList?: PlayListPlacement;
82
+ interface?: InterfacePlacement;
83
+ };
84
+ }
85
+ ```
86
+
87
+ Prop | Type | Default
88
+ --- | --- | ---
89
+ `playList` | [PlayList](#playlist) | [ ]
90
+ `audioInitialState` | [AudioInitialState](#audioinitialstate) | isPlaying: false </br>repeatType: "ALL" </br>volume: 1
91
+ `activeUI` | [ActiveUI](#activeui) | playButton : true
92
+ `customIcons` | [CustomIcons](#customicons) | undefined
93
+ `coverImgsCss` | [CoverImgsCss](#coverimgscss) | undefined
94
+ `placement` | [Placement](#placement) | playListPlacement : "bottom" </br>interfacePlacement :[DefaultInterfacePlacement](#default-interface-placement)
95
+
96
+ ## PlayList
97
+
98
+ ```tsx
99
+ type PlayList = Array<AudioData>;
100
+ type AudioData = {
101
+ src: string;
102
+ id: number;
103
+ index: number;
104
+ name?: string | ReactNode;
105
+ writer?: string | ReactNode;
106
+ img?: string;
107
+ description?: string | ReactNode;
108
+ customTrackInfo?: string | ReactNode;
109
+ };
110
+ ```
111
+
112
+ ## audioInitialState
113
+
114
+ ```tsx
115
+ type AudioInitialState = Omit<
116
+ React.AudioHTMLAttributes<HTMLAudioElement>,
117
+ "autoPlay"
118
+ > & {
119
+ isPlaying?: boolean;
120
+ repeatType?: RepeatType;
121
+ volume?: number;
122
+ currentTime?: number;
123
+ duration?: number;
124
+ curPlayId: number;
125
+ };
126
+ ```
127
+
128
+ ## activeUI
129
+
130
+ ```tsx
131
+ type ActiveUI = {
132
+ all: boolean;
133
+ playButton: boolean;
134
+ playList: PlayListUI;
135
+ prevNnext: boolean;
136
+ volume: boolean;
137
+ repeatType: boolean;
138
+ trackTime: TrackTimeUI;
139
+ trackInfo: boolean;
140
+ artwork: boolean;
141
+ progress: ProgressUI;
142
+ };
143
+ type TrackTimeUI = "separation-mode" | "unification-mode" | false;
144
+ type ProgressUI = "waveform" | "bar" | false;
145
+ type PlayListUI = "sortable" | "unSortable" | false;
146
+ ```
147
+
148
+ ## customIcons
149
+
150
+ ```tsx
151
+ type CustomIcons = {
152
+ play: ReactNode;
153
+ pause: ReactNode;
154
+ prev: ReactNode;
155
+ next: ReactNode;
156
+ repeatOne: ReactNode;
157
+ repeatAll: ReactNode;
158
+ repeatNone: ReactNode;
159
+ repeatShuffle: ReactNode;
160
+ volumeFull: ReactNode;
161
+ volumeHalf: ReactNode;
162
+ volumeMuted: ReactNode;
163
+ playList: ReactNode;
164
+ };
165
+ ```
166
+
167
+ ## coverImgsCss
168
+
169
+ ```tsx
170
+ interface CoverImgsCss {
171
+ artwork?: React.CSSProperties;
172
+ listThumbnail?: React.CSSProperties;
173
+ }
174
+ ```
175
+
176
+ ## placement
177
+
178
+ ```tsx
179
+ type PlayerPlacement =
180
+ | "bottom"
181
+ | "top"
182
+ | "bottom-left"
183
+ | "bottom-right"
184
+ | "top-left"
185
+ | "top-right";
186
+
187
+ type PlayListPlacement = "bottom" | "top";
188
+
189
+ type InterfacePlacement = {
190
+ templateArea: InterfaceGridTemplateArea;
191
+ itemCustomArea?: InterfaceGridItemArea;
192
+ };
193
+
194
+ type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>
195
+ type InterfacePlacementKey =
196
+ | Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime">
197
+ | "trackTimeCurrent"
198
+ | "trackTimeDuration";
199
+ type InterfacePlacementValue = "row1-1" | "row1-2" | "row1-3" | "row1-4" | ... more ... | "row9-9";
200
+
201
+ type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
202
+ /** example
203
+ * check grid item MDN
204
+ * progress : 2-4
205
+ * repeatBtn : row1-4 / 2 / row1-4 / 10
206
+ */
207
+ ```
208
+
209
+ ### Default interface placement
210
+ ```tsx
211
+ const defaultInterfacePlacement = {
212
+ templateArea: {
213
+ artwork: "row1-1",
214
+ trackInfo: "row1-2",
215
+ trackTimeCurrent: "row1-3",
216
+ trackTimeDuration: "row1-4",
217
+ progress: "row1-5",
218
+ repeatType: "row1-6",
219
+ volume: "row1-7",
220
+ playButton: "row1-8",
221
+ playList: "row1-9",
222
+ },
223
+ };
224
+ ```
225
+
226
+ # Override Style
227
+
228
+ ### Theme mode ( dark-mode )
229
+
230
+ > it apply dark-mode depending on `system-theme`
231
+ > </br>
232
+ > you can customize color-theme by `css-variable` of `react-spectrum` `theme-default`
233
+
234
+
235
+ ## ID & Classnames
236
+
237
+ ### root ID
238
+
239
+ - rm-audio-player
240
+
241
+ ### root ClassName
242
+
243
+ - rm-audio-player-provider
244
+
245
+ ### color variables
246
+
247
+ ```tsx
248
+ --rm-audio-player-volume-background: #ccc;
249
+ --rm-audio-player-volume-panel-background: #f2f2f2;
250
+ --rm-audio-player-volume-panel-border: #ccc;
251
+ --rm-audio-player-volume-thumb: #e5e5e5;
252
+ --rm-audio-player-volume-fill: rgba(0, 0, 0, 0.5);
253
+ --rm-audio-player-volume-track: #ababab;
254
+ --rm-audio-player-track-current-time: #0072F5;
255
+ --rm-audio-player-track-duration: #8c8c8c;
256
+ --rm-audio-player-progress-bar: #0072F5;
257
+ --rm-audio-player-progress-bar-background: #D1D1D1;
258
+ --rm-audio-player-waveform-cursor: var(--spectrum-alias-text-color);
259
+ --rm-audio-player-waveform-background: var(--rm-audio-player-progress-bar-background);
260
+ --rm-audio-player-waveform-bar: var(--rm-audio-player-progress-bar);
261
+ --rm-audio-player-sortable-list-button-active: #0072F5;
262
+ --rm-audio-player-selected-list-item-background: var(--spectrum-alias-border-color);
263
+
264
+ // ...spectrim theme palette and so on... //
265
+ ```
266
+
267
+ # ****Example****
268
+ ```tsx
269
+ function App() {
270
+ return (
271
+ <div>
272
+ <AudioPlayer
273
+ playList={playList}
274
+ audioInitialState={{
275
+ muted: true,
276
+ volume: 0.2,
277
+ curPlayId: 1,
278
+ }}
279
+ placement={{
280
+ interface: {
281
+ templateArea: {
282
+ trackTimeDuration: "row1-5",
283
+ progress: "row1-4",
284
+ playButton: "row1-6",
285
+ repeatType: "row1-7",
286
+ volume: "row1-8",
287
+ },
288
+ },
289
+ player: "bottom-left",
290
+ }}
291
+ activeUI={{
292
+ all: true,
293
+ trackTime: "separation-mode",
294
+ progress: "waveform",
295
+ }}
296
+ />
297
+ </div>
298
+ );
299
+ }
300
+ ```