React,TS的音乐播放插件,歌词同步功能,适配PC和移动端;A music player build with react and typescript for mobile and PC
react-cool-music-player
Responsive audio play assembly adaptive with PC and mobile devices. All icons and texts are customizable. Theme colors can be modified. Synchronized scrolling of lyrics is supported.
Click here to view a demonstration | 中文文档
Adaptive with PCs and mobile devices. Popup of the play detail page is supported on mobile devices.
install
npm install react-cool-music-playerUse in code
…Audio data structure in the player:
interface IAudio {
/*Audio link*/
src: string
/*author*/
artist: string
/*audio name*/
name: string
/*audio image*/
img: string
/*audio ID*/
id: string
/*lyrics*/
lyric?: string
/*lyric translation*/
tLyric?: string
/*disabled or not*/
disabled?: boolean
/*reasons for being disabled*/
disabledReason?: string | React.ReactNode
}| API | Description | Type | Default |
|---|---|---|---|
| data | Audio data introduced into the assembly, which is displayed in the playlist | IAudio[] | - |
| play | Controls the player to start and stop playing | boolean | false |
| playListPlaceholder | Placeholder text when the playlist is empty | string | 'No data' |
| currentAudio | Can control audio of the current player. If it is not introduced, the audio to be played in the player is the first audio in the playlist by default | IAudio | - |
| playListShow | Facilitates externally controlling display and hiding of the playlist | boolean | false |
| showPlayDetail | Whether play details are displayed upon click on the song icon (valid on mobile devices) | boolean | true |
| playDetailShow | Facilitates externally controlling display and hiding of the play details (valid on mobile devices) | boolean | false |
| detailBackground | Background of the play detail page (valid on mobile devices) | React.ReactNode |
- |
| volume | Volume, which, after being introduced into the assembly, can control the volume size of the player, ranging from 0 to 1 | number | 0.5 |
| zIndex | z-index value of the player | number | 1000 |
| showLyricNormal | Whether to display lyrics on non-mobile devices | boolean | false |
| showDetailLyric | Whether to display lyrics on the song detail page on mobile devices | boolean | false |
| showLyricMini | Whether to display mini lyrics on mobile devices | boolean | false |
| playMode | Play mode, which, after being introduced, can control the play modes of the playlist in the player (play in order, random play, single cycle) | order,random,loop |
order |
| lyric | Introduced lyric data when lyrics are loaded asynchronously | string | - |
| tLyric | Introduced lyric translation when lyrics are loaded asynchronously if it is needed to display lyric translation | string | - |
| lyricLoading | Loading status display for loading lyrics asynchronously | boolean | false |
| lyricPlaceholder | Placeholder element when lyric data is empty | React.ReactNode or string |
false |
| showProgressControlByLyricScroll | Whether it is needed to manually scroll lyrics to adjust the play progress in play details on mobile devices | boolean | true |
| avatarPlaceholder | Placeholder element of the song icon when the song image is empty | React.ReactNode |
|
| actions | An action group displayed in the player on non-mobile devices, between the play mode button and the volume control button | Array React.ReactNode> | [] |
| detailActionTopRight | An action element displayed at the upper right corner in the play details on mobile devices | (data: IAudio) => React.ReactNode | - |
| detailActionsBottom | An action group displayed above the progress bar in the play details on mobile devices | Array React.ReactNode> | [] |
| playListAudioActions | An action group of each piece of audio in the playlist, located on the right side of the song name, displayed in the activated status on a mobile terminal and when a non-mobile devices hovers | Array React.ReactNode> | [] |
| playListHeader | Two (left and right) elements on the top of the playlist | { headerLeft?: React.ReactNode or string, headerRight?: React.ReactNode or string } | headerLeft: 'Play list', headerRight: '' |
| primaryColor | Theme colors | string
No open issues yet, or sync has not completed.