Update video player to use native HTML5 controls

Replace iframe-based video player with native HTML5 video element and update player controls logic.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 2eb1084e-b728-4449-9231-f1665924c8d5
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2eb1084e-b728-4449-9231-f1665924c8d5/ODcEkiW
This commit is contained in:
sebastjanartic 2025-08-28 20:54:06 +00:00
parent b18e25e4c9
commit d782a732b2

View File

@ -53,9 +53,6 @@ function formatDate(date: Date | string): string {
export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos = [], onVideoChange }: BunnyVideoModalProps) { export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos = [], onVideoChange }: BunnyVideoModalProps) {
const [showShareMenu, setShowShareMenu] = useState(false); const [showShareMenu, setShowShareMenu] = useState(false);
const [showControls, setShowControls] = useState(false);
const [controlsTimeout, setControlsTimeout] = useState<NodeJS.Timeout | null>(null);
const [showPlayButton, setShowPlayButton] = useState(true);
// Navigation functions // Navigation functions
const getCurrentVideoIndex = () => { const getCurrentVideoIndex = () => {
@ -80,33 +77,6 @@ export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos
} }
}; };
// Controls visibility logic
const showControlsTemporarily = () => {
setShowControls(true);
if (controlsTimeout) {
clearTimeout(controlsTimeout);
}
const timeout = setTimeout(() => {
setShowControls(false);
}, 4000); // Hide after 4 seconds
setControlsTimeout(timeout);
};
const handleVideoClick = (e: React.MouseEvent) => {
e.stopPropagation();
showControlsTemporarily();
setShowPlayButton(false); // Hide play button when clicked
};
const handlePlayButtonClick = (e: React.MouseEvent) => {
e.stopPropagation();
setShowPlayButton(false);
// Try to trigger video play via postMessage to iframe
const iframe = document.querySelector('iframe');
if (iframe && iframe.contentWindow) {
iframe.contentWindow.postMessage('{"method":"play"}', '*');
}
};
useEffect(() => { useEffect(() => {
const handleEscape = (e: KeyboardEvent) => { const handleEscape = (e: KeyboardEvent) => {
@ -288,37 +258,27 @@ export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos
<div className="flex-1 flex flex-col lg:flex-row gap-4 min-h-0"> <div className="flex-1 flex flex-col lg:flex-row gap-4 min-h-0">
{/* Main video player */} {/* Main video player */}
<div className="flex-1"> <div className="flex-1">
<div <div className="relative w-full aspect-video bg-black rounded-lg overflow-hidden">
className="relative w-full h-0 pb-[56.25%] bg-black rounded-lg overflow-hidden" {video.videoUrl ? (
> <video
{video.videoUrlIframe ? ( className="w-full h-full object-contain"
<iframe controls
src={video.videoUrlIframe} preload="metadata"
className="absolute inset-0 w-full h-full" poster={video.thumbnailUrl}
frameBorder="0" onPlay={handleVideoPlay}
allowFullScreen >
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" <source src={video.videoUrl} type="video/mp4" />
onLoad={handleVideoPlay} <source src={video.videoUrl.replace('.mp4', '.webm')} type="video/webm" />
title={video.title} <source src={video.videoUrl.replace('.mp4', '.m3u8')} type="application/x-mpegURL" />
/> Vaš brskalnik ne podpira video predvajanja.
</video>
) : ( ) : (
<div className="absolute inset-0 flex items-center justify-center text-white"> <div className="absolute inset-0 flex items-center justify-center text-white">
<p>Video ni na voljo</p> <p>Video ni na voljo</p>
</div> </div>
)} )}
{/* Central play button */} {/* Navigation buttons - always visible */}
{showPlayButton && (
<Button
onClick={handlePlayButtonClick}
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-black bg-opacity-60 hover:bg-opacity-80 text-white border-none p-4 rounded-full z-40 transition-all duration-300"
size="lg"
>
<Play className="w-8 h-8 fill-white" />
</Button>
)}
{/* Navigation buttons - show/hide with controls */}
{videos.length > 1 && ( {videos.length > 1 && (
<> <>
<Button <Button
@ -337,8 +297,6 @@ export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos
> >
<ChevronRight className="w-6 h-6" /> <ChevronRight className="w-6 h-6" />
</Button> </Button>
</> </>
)} )}
</div> </div>