import { FunctionComponent, useState } from 'react'
import ReactPlayer from 'react-player'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import DownloadButtonGroup from '../DownloadBtnGtoup'
enum PlayerState {
Loading,
Ready,
Playing,
Paused,
}
const AudioPreview: FunctionComponent<{ file: any }> = ({ file }) => {
const [playerStatus, setPlayerStatus] = useState(PlayerState.Loading)
return (
<>
{playerStatus === PlayerState.Loading ? (
) : (
)}
{file.name}
Last modified:{' '}
{new Date(file.lastModifiedDateTime).toLocaleString(undefined, {
dateStyle: 'short',
timeStyle: 'short',
})}
{
setPlayerStatus(PlayerState.Ready)
}}
onPlay={() => {
setPlayerStatus(PlayerState.Playing)
}}
onPause={() => {
setPlayerStatus(PlayerState.Paused)
}}
onError={() => setPlayerStatus(PlayerState.Paused)}
onEnded={() => setPlayerStatus(PlayerState.Paused)}
/>
>
)
}
export default AudioPreview