2021-06-24 13:54:59 +00:00
|
|
|
import { FunctionComponent } from 'react'
|
|
|
|
import ReactPlayer from 'react-player'
|
2021-08-15 20:26:08 +00:00
|
|
|
import Image from 'next/image'
|
|
|
|
import { useRouter } from 'next/router'
|
2021-08-23 14:02:06 +00:00
|
|
|
import { useClipboard } from 'use-clipboard-copy'
|
2021-08-15 20:26:08 +00:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
|
|
import toast, { Toaster } from 'react-hot-toast'
|
2021-06-24 13:54:59 +00:00
|
|
|
|
2021-12-17 15:16:18 +00:00
|
|
|
import { getBaseUrl } from '../../utils/getBaseUrl'
|
2021-12-29 07:23:47 +00:00
|
|
|
import { DownloadButton } from '../DownloadBtnGtoup'
|
2021-06-25 14:15:00 +00:00
|
|
|
|
2021-12-17 15:16:18 +00:00
|
|
|
const VideoPreview: FunctionComponent<{ file: any }> = ({ file }) => {
|
2021-08-15 20:26:08 +00:00
|
|
|
const { asPath } = useRouter()
|
2021-08-23 14:02:06 +00:00
|
|
|
const clipboard = useClipboard()
|
2021-08-15 20:26:08 +00:00
|
|
|
|
2021-06-24 13:54:59 +00:00
|
|
|
return (
|
2021-06-25 14:15:00 +00:00
|
|
|
<>
|
2021-12-17 06:35:24 +00:00
|
|
|
<div className="dark:bg-gray-900 p-3 bg-white rounded">
|
2021-12-18 01:43:24 +00:00
|
|
|
<ReactPlayer
|
|
|
|
className="aspect-video"
|
|
|
|
url={file['@microsoft.graph.downloadUrl']}
|
|
|
|
controls
|
|
|
|
width="100%"
|
|
|
|
height="100%"
|
|
|
|
config={{ file: { forceVideo: true } }}
|
|
|
|
/>
|
2021-06-25 14:15:00 +00:00
|
|
|
</div>
|
2021-08-15 20:26:08 +00:00
|
|
|
|
2021-12-29 07:23:47 +00:00
|
|
|
<div className="flex flex-wrap justify-center mt-4 gap-2">
|
2021-12-17 07:28:11 +00:00
|
|
|
<Toaster />
|
2021-08-15 20:26:08 +00:00
|
|
|
|
2021-12-29 07:23:47 +00:00
|
|
|
<DownloadButton
|
|
|
|
onClickCallback={() => window.open(file['@microsoft.graph.downloadUrl'])}
|
|
|
|
btnColor="blue"
|
|
|
|
btnText="Download"
|
|
|
|
btnIcon="file-download"
|
|
|
|
/>
|
|
|
|
<DownloadButton
|
|
|
|
onClickCallback={() =>
|
|
|
|
window.open(`/api/proxy?url=${encodeURIComponent(file['@microsoft.graph.downloadUrl'])}`)
|
|
|
|
}
|
2021-12-29 07:26:04 +00:00
|
|
|
btnColor="teal"
|
2021-12-29 07:23:47 +00:00
|
|
|
btnText="Proxy download"
|
|
|
|
btnIcon="download"
|
|
|
|
/>
|
|
|
|
<DownloadButton
|
|
|
|
onClickCallback={() => {
|
2021-08-23 14:02:06 +00:00
|
|
|
clipboard.copy(`${getBaseUrl()}/api?path=${asPath}&raw=true`)
|
2021-08-15 20:26:08 +00:00
|
|
|
toast.success('Copied direct link to clipboard.')
|
|
|
|
}}
|
2021-12-29 07:23:47 +00:00
|
|
|
btnColor="yellow"
|
|
|
|
btnText="Copy direct link"
|
|
|
|
btnIcon="copy"
|
|
|
|
/>
|
2021-08-15 20:26:08 +00:00
|
|
|
|
2021-12-29 07:23:47 +00:00
|
|
|
<DownloadButton
|
|
|
|
onClickCallback={() => window.open(`iina://weblink?url=${file['@microsoft.graph.downloadUrl']}`)}
|
|
|
|
btnText="IINA"
|
|
|
|
btnImage="/players/iina.png"
|
|
|
|
/>
|
|
|
|
<DownloadButton
|
|
|
|
onClickCallback={() => window.open(`vlc://${file['@microsoft.graph.downloadUrl']}`)}
|
|
|
|
btnText="VLC"
|
|
|
|
btnImage="/players/vlc.png"
|
|
|
|
/>
|
|
|
|
<DownloadButton
|
|
|
|
onClickCallback={() => window.open(`potplayer://${file['@microsoft.graph.downloadUrl']}`)}
|
|
|
|
btnText="PotPlayer"
|
|
|
|
btnImage="/players/potplayer.png"
|
|
|
|
/>
|
2021-06-24 13:54:59 +00:00
|
|
|
</div>
|
2021-06-25 14:15:00 +00:00
|
|
|
</>
|
2021-06-24 13:54:59 +00:00
|
|
|
)
|
|
|
|
}
|
2021-12-17 15:16:18 +00:00
|
|
|
|
|
|
|
export default VideoPreview
|