11'use client' ;
22
3- import { PlayCircleOutlined , SoundFilled , SoundOutlined } from '@ant-design/icons' ;
3+ import {
4+ FullscreenOutlined ,
5+ PlayCircleOutlined ,
6+ SoundFilled ,
7+ SoundOutlined ,
8+ } from '@ant-design/icons' ;
49import { motion , useInView } from 'framer-motion' ;
510import { useEffect , useRef , useState } from 'react' ;
611
7- import { cn } from '@/utils/css-class' ;
8-
912export default function SFNVideo ( ) {
1013 const ref = useRef ( null ) ;
1114 const videoRef = useRef < HTMLVideoElement > ( null ) ;
@@ -42,6 +45,20 @@ export default function SFNVideo() {
4245 }
4346 } ;
4447
48+ const toggleFullscreen = ( ) => {
49+ if ( videoRef . current ) {
50+ if ( ! document . fullscreenElement ) {
51+ videoRef . current . requestFullscreen ( ) . catch ( ( _error ) => {
52+ // Fullscreen might not be available
53+ } ) ;
54+ } else {
55+ document . exitFullscreen ( ) . catch ( ( _error ) => {
56+ // Exit fullscreen might fail
57+ } ) ;
58+ }
59+ }
60+ } ;
61+
4562 const handleVideoClick = ( ) => {
4663 if ( videoRef . current ) {
4764 if ( videoRef . current . paused ) {
@@ -61,7 +78,7 @@ export default function SFNVideo() {
6178 } ;
6279
6380 return (
64- < div ref = { ref } className = "relative h-full w-full px-8 py-12 md:px-[10vw ] md:py-[15vh]" >
81+ < div ref = { ref } className = "relative h-full w-full px-8 py-12 md:px-[15vw ] md:py-[15vh]" >
6582 < motion . video
6683 ref = { videoRef }
6784 muted = { isMuted }
@@ -95,18 +112,28 @@ export default function SFNVideo() {
95112 </ button >
96113 ) }
97114
98- { /* Mute Button */ }
99- < button
100- type = "button"
101- onClick = { toggleMute }
102- className = { cn (
103- 'bg-opacity-50 hover:bg-opacity-70 absolute top-52 right-[12vw] z-10 flex h-12 w-12 items-center justify-center rounded-full bg-black text-white transition-all' ,
104- isMuted ? 'Unmute video' : 'Mute video'
105- ) }
106- aria-label = { isMuted ? 'Unmute video' : 'Mute video' }
107- >
108- { isMuted ? < SoundOutlined className = "text-xl" /> : < SoundFilled className = "text-xl" /> }
109- </ button >
115+ { /* Control Buttons */ }
116+ < div className = "absolute top-52 right-[17vw] z-10 flex gap-3" >
117+ { /* Mute Button */ }
118+ < button
119+ type = "button"
120+ onClick = { toggleMute }
121+ className = "bg-opacity-50 hover:bg-opacity-70 flex h-12 w-12 items-center justify-center rounded-full bg-black text-white transition-all"
122+ aria-label = { isMuted ? 'Unmute video' : 'Mute video' }
123+ >
124+ { isMuted ? < SoundOutlined className = "text-xl" /> : < SoundFilled className = "text-xl" /> }
125+ </ button >
126+
127+ { /* Fullscreen Button */ }
128+ < button
129+ type = "button"
130+ onClick = { toggleFullscreen }
131+ className = "bg-opacity-50 hover:bg-opacity-70 flex h-12 w-12 items-center justify-center rounded-full bg-black text-white transition-all"
132+ aria-label = "Toggle fullscreen"
133+ >
134+ < FullscreenOutlined className = "text-xl" />
135+ </ button >
136+ </ div >
110137 </ div >
111138 ) ;
112139}
0 commit comments