Skip to content

Commit cd52b7b

Browse files
committed
fix no sound
1 parent 85f7188 commit cd52b7b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

app/page.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
'use client';
2+
13
import Image from "next/image";
4+
import { useEffect, useRef } from "react";
25

36
export default function Page() {
7+
const videoRef = useRef(null);
8+
9+
useEffect(() => {
10+
const timer = setTimeout(() => {
11+
if (videoRef.current) {
12+
videoRef.current.muted = false;
13+
}
14+
}, 250);
15+
16+
return () => clearTimeout(timer);
17+
}, []);
18+
419
return (
520
<>
621
<div className="flex justify-center items-center min-h-screen bg-purple-200">
@@ -10,9 +25,11 @@ export default function Page() {
1025
alt="Saitama Ok"
1126
width={500}
1227
height={500} />
13-
<video autoPlay muted height="500" width="500">
14-
<source src="/never-gonna-give-up.mp4" type="video/mp4" />
15-
</video>
28+
<div>
29+
<video ref={videoRef} loop autoPlay muted height="500" width="500">
30+
<source src="/never-gonna-give-up.mp4" type="video/mp4" />
31+
</video>
32+
</div>
1633
</div>
1734
</div>
1835
</>

0 commit comments

Comments
 (0)