React-IMusic is an HTML5 Audio integration component.
Simply install it using npm/yarn.
npm install react-imusic
import Music from 'react-imuisc';
<Music
src={list[index].url}
play={play}
onProgress={d => {
// ...
}}
/>
You can also directly view the Example code.
name | type | default | description |
---|---|---|---|
src | string | null | @required |
play | bool | false | |
autoPlay | bool | false | |
preload | bool | true | |
initSeek | number | 0 | |
onProgress | function | d => d, | |
onError | function | e => e, | |
onLoadStart | function | e => e, | |
onLoadMetaData | function | e => e, | |
onLoad | function | e => e, | |
onPlay | function | e => e, | |
onPause | function | e => e, | |
onEnd | function | e => e, | |
onCanplay | function | e => e, | |
onCanplayThrough | function | e => e, | |
onRateChange | function | e => e, | |
onDurationChange | function | e => e, | |
onVolumeChange | function | e => e, | |
onSuspend | function | e => e, | |
onWaiting | function | e => e, | |
onPlaying | function | e => e, | |
onSeeking | function | e => e, | |
onSeeked | function | e => e, |
onProgress callback param data:
{
currentTime: number,
duration: number,
seeking: boolean,
buffered: number,
seekable: number,
percent: number,
networkState: number,
}
name | params | description |
---|---|---|
reLoad | () | |
isPlay | () | |
seek | (val: number) |