Fix video player issues by restructuring component logic
Refactor VideoModal component to fix video player issues by moving VAST player logic and cleanup logic to ensure proper initialization and resource management. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/5h9ujRr
This commit is contained in:
parent
175001993a
commit
db5a31e7c1
@ -91,11 +91,6 @@ export default function VideoModal({ video, isOpen, onClose, enableAds = true }:
|
||||
document.body.style.overflow = "";
|
||||
};
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
// Switch to VAST player for monetization
|
||||
if (isOpen && video && useVASTPlayer && enableAds) {
|
||||
return <VASTPlayer video={video} onClose={onClose} enableAds={enableAds} />;
|
||||
}
|
||||
|
||||
// Initialize HLS when video is available
|
||||
useEffect(() => {
|
||||
@ -276,6 +271,20 @@ export default function VideoModal({ video, isOpen, onClose, enableAds = true }:
|
||||
};
|
||||
}, [isOpen, video]);
|
||||
|
||||
// Cleanup controls timeout - moved before any returns
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (controlsTimeout) {
|
||||
clearTimeout(controlsTimeout);
|
||||
}
|
||||
};
|
||||
}, [controlsTimeout]);
|
||||
|
||||
// Switch to VAST player for monetization - after all hooks
|
||||
if (isOpen && video && useVASTPlayer && enableAds) {
|
||||
return <VASTPlayer video={video} onClose={onClose} enableAds={enableAds} />;
|
||||
}
|
||||
|
||||
// Function to capture video thumbnail
|
||||
const captureVideoThumbnail = () => {
|
||||
try {
|
||||
@ -351,14 +360,6 @@ export default function VideoModal({ video, isOpen, onClose, enableAds = true }:
|
||||
setControlsTimeout(timeout);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (controlsTimeout) {
|
||||
clearTimeout(controlsTimeout);
|
||||
}
|
||||
};
|
||||
}, [controlsTimeout]);
|
||||
|
||||
const getShareUrl = () => {
|
||||
if (!video?.id) return window.location.origin;
|
||||
return `${window.location.origin}?video=${video.id}`;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user