react-modern-audio-player 0.0.3 → 1.1.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 CHANGED
@@ -1,53 +1,303 @@
1
- # deploy on 0.0.3 for test
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
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>
4
20
 
5
- ### Icon Imgs
6
- use icon module - `react-icons`
7
- - pass by props `iconImgs`
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="">
8
24
 
9
- ### ID
10
- - rs-audio-player-audio
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="">
11
28
 
12
- ### classnames
13
- - playlist classnames
14
- - play-list-trigger-container
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
29
+ > Position Change
30
+ > <img width="110%" src="https://user-images.githubusercontent.com/70849655/180435493-2c2e08c5-b67b-4ab7-aded-5a0403d42050.png" alt="">
23
31
 
24
- - interface classnames
25
- - interface-container
26
- - interface-grid
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 <br/> volumeSlider: 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
+ volumeSlider: boolean;
138
+ repeatType: boolean;
139
+ trackTime: TrackTimeUI;
140
+ trackInfo: boolean;
141
+ artwork: boolean;
142
+ progress: ProgressUI;
143
+ };
144
+ type TrackTimeUI = "separation-mode" | "unification-mode" | false;
145
+ type ProgressUI = "waveform" | "bar" | false;
146
+ type PlayListUI = "sortable" | "unSortable" | false;
147
+ ```
148
+
149
+ ## customIcons
150
+
151
+ ```tsx
152
+ type CustomIcons = {
153
+ play: ReactNode;
154
+ pause: ReactNode;
155
+ prev: ReactNode;
156
+ next: ReactNode;
157
+ repeatOne: ReactNode;
158
+ repeatAll: ReactNode;
159
+ repeatNone: ReactNode;
160
+ repeatShuffle: ReactNode;
161
+ volumeFull: ReactNode;
162
+ volumeHalf: ReactNode;
163
+ volumeMuted: ReactNode;
164
+ playList: ReactNode;
165
+ };
166
+ ```
167
+
168
+ ## coverImgsCss
169
+
170
+ ```tsx
171
+ interface CoverImgsCss {
172
+ artwork?: React.CSSProperties;
173
+ listThumbnail?: React.CSSProperties;
174
+ }
175
+ ```
176
+
177
+ ## placement
178
+
179
+ ```tsx
180
+ type PlayerPlacement =
181
+ | "bottom"
182
+ | "top"
183
+ | "bottom-left"
184
+ | "bottom-right"
185
+ | "top-left"
186
+ | "top-right";
187
+
188
+ type PlayListPlacement = "bottom" | "top";
189
+
190
+ type InterfacePlacement = {
191
+ templateArea: InterfaceGridTemplateArea;
192
+ itemCustomArea?: InterfaceGridItemArea;
193
+ };
194
+
195
+ type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>
196
+ type InterfacePlacementKey =
197
+ | Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime">
198
+ | "trackTimeCurrent"
199
+ | "trackTimeDuration";
200
+ type InterfacePlacementValue = "row1-1" | "row1-2" | "row1-3" | "row1-4" | ... more ... | "row9-9";
201
+
202
+ type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
203
+ /** example
204
+ * check grid item MDN
205
+ * progress : 2-4
206
+ * repeatBtn : row1-4 / 2 / row1-4 / 10
207
+ */
208
+ ```
209
+
210
+ ### Default interface placement
211
+ ```tsx
212
+ const defaultInterfacePlacement = {
213
+ templateArea: {
214
+ artwork: "row1-1",
215
+ trackInfo: "row1-2",
216
+ trackTimeCurrent: "row1-3",
217
+ trackTimeDuration: "row1-4",
218
+ progress: "row1-5",
219
+ repeatType: "row1-6",
220
+ volume: "row1-7",
221
+ playButton: "row1-8",
222
+ playList: "row1-9",
223
+ },
224
+ };
225
+ ```
226
+
227
+ # Override Style
228
+
229
+ ### Theme mode ( dark-mode )
230
+
231
+ > it apply dark-mode depending on `system-theme`
232
+ > </br>
233
+ > you can customize color-theme by `css-variable` of `react-spectrum` `theme-default`
234
+
235
+
236
+ ## ID & Classnames
237
+
238
+ ### root ID
239
+
240
+ - rm-audio-player
241
+
242
+ ### root ClassName
243
+
244
+ - rm-audio-player-provider
27
245
 
28
246
  ### color variables
29
- - --rs-audio-player-volume-fill
30
- - --rs-audio-player-volume-track
31
- - --rs-audio-player-volume-thumb
32
- - --rs-audio-player-volume-background
33
- - --rs-audio-player-volume-panel-background
34
- - --rs-audio-player-volume-panel-border
35
- - --rs-audio-player-track-current-time-color
36
- - --rs-audio-player-track-duration-color
37
- - --rs-audio-player-progress-color
38
- - --rs-audio-player-selected-list-item-background
39
-
40
- ## UI Placement
41
-
42
- ## flexible and customable UI
43
- it can offer variant UI and you can also place each component easily
44
- `Volume Tooltip` is wrapped with `tooltip` of `react-spectrum`
45
-
46
- ### Theme mode
47
- it apply color-theme from `system-theme`
48
- and you can customize color-theme from `css-variable` of `theme-default` of `react-spectrum`
49
-
50
- ### grid item custom area
51
- progress = 2-4
52
- playBtn = 2-4
53
- repeatBtn = row1-4 / 2 / row1-4 / 10
247
+
248
+ ```tsx
249
+ --rm-audio-player-interface-container:var(--spectrum-global-color-gray-100);
250
+ --rm-audio-player-volume-background: #ccc;
251
+ --rm-audio-player-volume-panel-background:#f2f2f2;
252
+ --rm-audio-player-volume-panel-border:#ccc;
253
+ --rm-audio-player-volume-thumb: #d3d3d3;
254
+ --rm-audio-player-volume-fill:rgba(0, 0, 0, 0.5);
255
+ --rm-audio-player-volume-track:#ababab;
256
+ --rm-audio-player-track-current-time:#0072F5;
257
+ --rm-audio-player-track-duration:#8c8c8c;
258
+ --rm-audio-player-progress-bar:#0072F5;
259
+ --rm-audio-player-progress-bar-background:#D1D1D1;
260
+ --rm-audio-player-waveform-cursor:var(--spectrum-global-color-gray-800);
261
+ --rm-audio-player-waveform-background:var(--rm-audio-player-progress-bar-background);
262
+ --rm-audio-player-waveform-bar:var(--rm-audio-player-progress-bar);
263
+ --rm-audio-player-sortable-list:var(--spectrum-global-color-gray-200);
264
+ --rm-audio-player-sortable-list-button-active:#0072F5;
265
+ --rm-audio-player-selected-list-item-background:var(--spectrum-global-color-gray-500);
266
+
267
+ // ...spectrum theme palette and so on... //
268
+ ```
269
+
270
+ # ****Example****
271
+ ```tsx
272
+ function App() {
273
+ return (
274
+ <div>
275
+ <AudioPlayer
276
+ playList={playList}
277
+ audioInitialState={{
278
+ muted: true,
279
+ volume: 0.2,
280
+ curPlayId: 1,
281
+ }}
282
+ placement={{
283
+ interface: {
284
+ templateArea: {
285
+ trackTimeDuration: "row1-5",
286
+ progress: "row1-4",
287
+ playButton: "row1-6",
288
+ repeatType: "row1-7",
289
+ volume: "row1-8",
290
+ },
291
+ },
292
+ player: "bottom-left",
293
+ }}
294
+ activeUI={{
295
+ all: true,
296
+ trackTime: "separation-mode",
297
+ progress: "waveform",
298
+ }}
299
+ />
300
+ </div>
301
+ );
302
+ }
303
+ ```