React Audio Player
Installation
yarn install @barstoolsports/react-audio-player
Usage
import { AudioPlayer } from '@barstoolsports/react-audio-player'
...
<AudioPlayer
trackTitle='Episode 1'
trackUrl='audio.mp3'
artist='Pardon My Take'
cover='cover.jpg'
duration='01:32:05'
createdAt={new Date()}
/>
Compact Player
import { AudioPlayer } from '@barstoolsports/react-audio-player'
...
<AudioPlayer compact trackUrl='audio.mp3' />
Methods
import { AudioPlayer } from '@barstoolsports/react-audio-player'
...
const player = useRef()
const play = () => {
player.current.play()
}
const pause = () => {
player.current.pause()
}
<AudioPlayer ref={player} trackUrl='audio.mp3' />
Callback Props
Prop | Description |
---|
onPlay | Called when audio starts/resumes playing |
onPause | Called when audio is paused |
onAudioSpeedChange | Called when audio playback speed is changed |
onSkip30 | Called when "Skip 30" button is pressed |
onBack15 | Called when "Back 15" button is pressed |