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 13:21:25 +00:00
|
|
|
import { getBaseUrl } from "../../utils/getBaseUrl"
|
2021-06-25 14:15:00 +00:00
|
|
|
|
2021-06-24 13:54:59 +00:00
|
|
|
export 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-06-25 14:15:00 +00:00
|
|
|
<div className="relative" style={{ paddingTop: '56.25%' }}>
|
|
|
|
<ReactPlayer
|
|
|
|
className="absolute top-0 left-0 w-full h-full"
|
|
|
|
url={file['@microsoft.graph.downloadUrl']}
|
|
|
|
controls
|
|
|
|
width="100%"
|
|
|
|
height="100%"
|
|
|
|
config={{ file: { forceVideo: true } }}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-15 20:26:08 +00:00
|
|
|
|
2021-09-04 14:15:09 +00:00
|
|
|
<div className="flex flex-wrap justify-center mt-4 space-x-2">
|
2021-12-17 07:28:11 +00:00
|
|
|
<Toaster />
|
2021-08-15 20:26:08 +00:00
|
|
|
<a
|
2021-12-17 07:28:11 +00:00
|
|
|
className="w-36 focus:outline-none focus:ring focus:ring-blue-300 hover:bg-blue-400 flex items-center justify-center flex-shrink-0 px-4 py-2 mb-2 space-x-4 text-white bg-blue-500 rounded"
|
2021-08-15 20:26:08 +00:00
|
|
|
href={file['@microsoft.graph.downloadUrl']}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<FontAwesomeIcon icon="file-download" />
|
|
|
|
<span>Download</span>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<button
|
2021-12-17 07:28:11 +00:00
|
|
|
className="focus:outline-none focus:ring focus:ring-yellow-300 hover:bg-yellow-400 flex items-center justify-center flex-shrink-0 w-48 px-4 py-2 mb-2 space-x-4 text-white bg-yellow-500 rounded"
|
2021-08-15 20:26:08 +00:00
|
|
|
onClick={() => {
|
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.')
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<FontAwesomeIcon icon="copy" />
|
|
|
|
<span>Copy direct link</span>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<a
|
2021-12-17 07:28:11 +00:00
|
|
|
className="focus:outline-none focus:ring focus:ring-gray-300 hover:bg-gray-600 flex items-center justify-center px-4 py-2 mb-2 space-x-2 text-white bg-gray-700 rounded"
|
2021-08-15 20:26:08 +00:00
|
|
|
href={`iina://weblink?url=${file['@microsoft.graph.downloadUrl']}`}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<Image src="/players/iina.png" alt="iina" width="28" height="28" />
|
|
|
|
<span>IINA</span>
|
|
|
|
</a>
|
|
|
|
<a
|
2021-12-17 07:28:11 +00:00
|
|
|
className="focus:outline-none focus:ring focus:ring-yellow-300 hover:bg-yellow-500 flex items-center justify-center px-4 py-2 mb-2 space-x-2 text-white bg-yellow-600 rounded"
|
2021-08-15 20:26:08 +00:00
|
|
|
href={`vlc://${file['@microsoft.graph.downloadUrl']}`}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<Image src="/players/vlc.png" alt="vlc" width="28" height="28" />
|
|
|
|
<span>VLC</span>
|
|
|
|
</a>
|
|
|
|
<a
|
2021-12-17 07:28:11 +00:00
|
|
|
className="focus:outline-none focus:ring focus:ring-yellow-100 hover:bg-yellow-400 flex items-center justify-center px-4 py-2 mb-2 space-x-2 text-white bg-yellow-400 rounded"
|
2021-08-15 20:26:08 +00:00
|
|
|
href={`potplayer://${file['@microsoft.graph.downloadUrl']}`}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<Image src="/players/potplayer.png" alt="potplayer" width="28" height="28" />
|
|
|
|
<span>PotPlayer</span>
|
|
|
|
</a>
|
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
|
|
|
)
|
|
|
|
}
|