import { OdFileObject } from '../../types' import { FC, useState } from 'react' import ReactPlayer from 'react-player' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import DownloadButtonGroup from '../DownloadBtnGtoup' import { DownloadBtnContainer, PreviewContainer } from './Containers' enum PlayerState { Loading, Ready, Playing, Paused, } const AudioPreview: FC<{ file: OdFileObject }> = ({ 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