-
-
Notifications
You must be signed in to change notification settings - Fork 211
/
index.d.ts
244 lines (234 loc) · 6.93 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import * as React from 'react'
export interface ReactJkMusicPlayerAudioInfo {
cover: string
currentTime: number
duration: number
ended: boolean
musicSrc: string
muted: boolean
name: string
networkState: number
paused: boolean
played: any
readyState: number
startDate: any
volume: number
lyric: string
currentLyric: string
playIndex: number
__PLAYER_KEY__: string
[key: string]: any
}
export type ReactJkMusicPlayerTheme = 'dark' | 'light' | 'auto'
export type ReactJkMusicPlayerMode = 'mini' | 'full'
export type ReactJkMusicPlayerPlayMode =
| 'order'
| 'orderLoop'
| 'singleLoop'
| 'shufflePlay'
export interface ReactJkMusicPlayerAudioListProps {
name: React.ReactNode
musicSrc: (() => Promise<string>) | string
singer?: React.ReactNode
cover?: string
lyric?: string
duration?: number
[key: string]: any
}
export interface ReactJkMusicPlayerInstance extends HTMLAudioElement {
destroy?: () => void
updatePlayIndex?: (index: number) => void
playByIndex?: (index: number) => void
playNext?: () => void
playPrev?: () => void
togglePlay?: () => void
clear?: () => void
sortable?: any
}
export interface ReactJkMusicPlayerIcon {
pause?: React.ReactNode
play?: React.ReactNode
destroy?: React.ReactNode
close?: React.ReactNode
delete?: React.ReactNode
download?: React.ReactNode
toggle?: React.ReactNode
lyric?: React.ReactNode
volume?: React.ReactNode
mute?: React.ReactNode
next?: React.ReactNode
prev?: React.ReactNode
playLists?: React.ReactNode
reload?: React.ReactNode
loop?: React.ReactNode
order?: React.ReactNode
orderLoop?: React.ReactNode
shuffle?: React.ReactNode
loading?: React.ReactNode
}
export interface ReactJkMusicPlayerCustomLocale {
playModeText: {
order: React.ReactNode
orderLoop: React.ReactNode
singleLoop: React.ReactNode
shufflePlay: React.ReactNode
}
openText: React.ReactNode
closeText: React.ReactNode
emptyText: React.ReactNode
clickToPlayText: React.ReactNode
clickToPauseText: React.ReactNode
nextTrackText: React.ReactNode
previousTrackText: React.ReactNode
reloadText: React.ReactNode
volumeText: React.ReactNode
playListsText: React.ReactNode
toggleLyricText: React.ReactNode
toggleMiniModeText: React.ReactNode
destroyText: React.ReactNode
downloadText: React.ReactNode
lightThemeText: React.ReactNode
darkThemeText: React.ReactNode
switchThemeText: React.ReactNode
removeAudioListsText: React.ReactNode
clickToDeleteText: (name: string) => React.ReactNode
controllerTitle: React.ReactNode
emptyLyricText: React.ReactNode
}
export type ReactJkMusicPlayerLocale =
| 'zh_CN'
| 'en_US'
| ReactJkMusicPlayerCustomLocale
export interface TransformedDownloadAudioInfo {
src: string
filename?: string
mimeType?: string
}
export interface ReactJkMusicPlayerProps {
style?: React.CSSProperties
className?: string
audioLists: Array<ReactJkMusicPlayerAudioListProps>
locale?: ReactJkMusicPlayerLocale
icon?: ReactJkMusicPlayerIcon
theme?: ReactJkMusicPlayerTheme
mode?: ReactJkMusicPlayerMode
defaultPlayMode?: ReactJkMusicPlayerPlayMode
playMode?: ReactJkMusicPlayerPlayMode
drag?: boolean
seeked?: boolean
autoPlay?: boolean
defaultPosition?: {
top?: number | string
left?: number | string
right?: number | string
bottom?: number | string
}
responsive?: boolean
quietUpdate?: boolean
onAudioPlay?: (audioInfo: ReactJkMusicPlayerAudioInfo) => void
onAudioPause?: (audioInfo: ReactJkMusicPlayerAudioInfo) => void
onAudioEnded?: (
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => void
onAudioAbort?: (
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => void
onAudioVolumeChange?: (volume: number) => void
onAudioError?: (
error: any,
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => void
onAudioProgress?: (audioInfo: ReactJkMusicPlayerAudioInfo) => void
onAudioSeeked?: (audioInfo: ReactJkMusicPlayerAudioInfo) => void
onAudioDownload?: (
audioInfo: ReactJkMusicPlayerAudioInfo,
transformedDownloadAudioInfo: TransformedDownloadAudioInfo,
) => void
onAudioReload?: (audioInfo: ReactJkMusicPlayerAudioInfo) => void
onThemeChange?: (theme: ReactJkMusicPlayerTheme) => void
onAudioListsChange?: (
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => void
onPlayModeChange?: (playMode: ReactJkMusicPlayerPlayMode) => void
onModeChange?: (mode: ReactJkMusicPlayerMode) => void
onAudioListsPanelChange?: (panelVisible: boolean) => void
onAudioPlayTrackChange?: (
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => void
onAudioListsSortEnd?: (oldIndex: number, newIndex: number) => void
showDownload?: boolean
showPlay?: boolean
showReload?: boolean
showPlayMode?: boolean
showThemeSwitch?: boolean
showMiniModeCover?: boolean
showDestroy?: boolean
showMediaSession?: boolean
toggleMode?: boolean
once?: boolean
extendsContent?: React.ReactNode
defaultVolume?: number
playModeShowTime?: number
bounds?: React.ReactNode
showMiniProcessBar?: boolean
loadAudioErrorPlayNext?: boolean
preload?: boolean | 'auto' | 'metadata' | 'none'
glassBg?: boolean
remember?: boolean
remove?: boolean
defaultPlayIndex?: number
playIndex?: number
lyricClassName?: string
showLyric?: boolean
getContainer?: () => HTMLElement
getAudioInstance?: (instance: ReactJkMusicPlayerInstance) => void
autoHiddenCover?: boolean
onBeforeAudioDownload?: (
audioInfo: ReactJkMusicPlayerAudioInfo,
) => Promise<TransformedDownloadAudioInfo>
clearPriorAudioLists?: boolean
autoPlayInitLoadPlayList?: boolean
spaceBar?: boolean
onBeforeDestroy?: (
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => Promise<void>
onDestroyed?: (
currentPlayId: string,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => Promise<void>
customDownloader?: (downloadAudioInfo: TransformedDownloadAudioInfo) => void
onCoverClick?: (
mode: ReactJkMusicPlayerMode,
audioLists: Array<ReactJkMusicPlayerAudioListProps>,
audioInfo: ReactJkMusicPlayerAudioInfo,
) => void
onPlayIndexChange?: (playIndex: number) => void
renderAudioTitle?: (
audioInfo: ReactJkMusicPlayerAudioInfo,
isMobile: boolean,
) => React.ReactNode
mobileMediaQuery?: string
volumeFade?: {
fadeIn?: number
fadeOut?: number
}
restartCurrentOnPrev?: boolean
sortableOptions?: object
}
export default class ReactJkMusicPlayer extends React.PureComponent<
ReactJkMusicPlayerProps,
any
> {}