diff --git a/src/components/VideoPlayerWithChapters.tsx b/src/components/VideoPlayerWithChapters.tsx index b2516c9..f1c04a0 100644 --- a/src/components/VideoPlayerWithChapters.tsx +++ b/src/components/VideoPlayerWithChapters.tsx @@ -34,6 +34,7 @@ export const VideoPlayerWithChapters = forwardRef(null); const wrapperRef = useRef(null); const playerRef = useRef(null); + const posterRef = useRef(null); const [currentChapterIndex, setCurrentChapterIndex] = useState(-1); const [isPlaying, setIsPlaying] = useState(false); @@ -93,12 +94,32 @@ export const VideoPlayerWithChapters = forwardRef setIsPlaying(true)); - player.on('pause', () => setIsPlaying(false)); - player.on('ended', () => setIsPlaying(false)); + // Get poster element + posterRef.current = player.elements.wrapper.querySelector('.plyr__poster') as HTMLDivElement; - // Apply custom accent color + // Track play/pause state to show/hide poster overlay + player.on('play', () => { + setIsPlaying(true); + if (posterRef.current) { + posterRef.current.style.opacity = '0'; + } + }); + + player.on('pause', () => { + setIsPlaying(false); + if (posterRef.current) { + posterRef.current.style.opacity = '1'; + } + }); + + player.on('ended', () => { + setIsPlaying(false); + if (posterRef.current) { + posterRef.current.style.opacity = '1'; + } + }); + + // Apply custom accent color and poster styles if (accentColor) { const style = document.createElement('style'); style.textContent = ` @@ -114,6 +135,11 @@ export const VideoPlayerWithChapters = forwardRef {youtubeId && ( - <> - {/* CSS Overlay to block YouTube UI interactions - shows when paused */} -
-