-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvideo.tsx
More file actions
41 lines (39 loc) · 943 Bytes
/
video.tsx
File metadata and controls
41 lines (39 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
interface VideoProps {
src: string
caption?: string
autoPlay?: boolean
loop?: boolean
muted?: boolean
width?: number
}
export function Video({
src,
caption,
autoPlay = true,
loop = true,
muted = true,
width
}: VideoProps) {
const videoPath = src.startsWith('/') ? src : `/videos/${src}`
return (
<figure className="my-6">
<div className="overflow-hidden rounded-lg border border-gray-200 shadow-sm dark:border-neutral-700 max-w-3xl mx-auto">
<video
src={videoPath}
autoPlay={autoPlay}
loop={loop}
muted={muted}
playsInline
controls
className="w-full h-auto"
style={width ? { maxWidth: width } : undefined}
/>
</div>
{caption && (
<figcaption className="mt-2 text-center text-sm text-gray-500 dark:text-neutral-400">
{caption}
</figcaption>
)}
</figure>
)
}