diff --git a/client/src/components/video-modal.tsx b/client/src/components/video-modal.tsx index 162e6cb..7a4c894 100644 --- a/client/src/components/video-modal.tsx +++ b/client/src/components/video-modal.tsx @@ -123,14 +123,33 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps) player.ready(() => { console.log('Video.js player ready'); - // Only initialize ads if plugins are properly loaded + // Initialize ads plugin first if (typeof (player as any).ads === 'function') { try { (player as any).ads({ - debug: false, - prerollTimeout: 1000 + debug: true, + prerollTimeout: 3000, + postrollTimeout: 3000, + timeout: 5000 }); console.log('Ads plugin initialized'); + + // Then initialize IMA plugin for VAST ads + if (typeof (player as any).ima === 'function') { + (player as any).ima({ + id: video.id, + adTagUrl: 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=' + Math.round(Math.random() * 100000000), + debug: true, + timeout: 5000, + maxRedirects: 4, + vpaidMode: 'ENABLED', + vpaidAllowed: true, + autoPlayAdBreaks: true, + adLabel: 'Advertisement', + showControlsForJSAds: true + }); + console.log('IMA plugin initialized with VAST ads'); + } } catch (error) { console.log('Ads plugin initialization failed:', error); } @@ -145,6 +164,27 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps) handleVideoPlay(); }); + // Ads event listeners + player.on('ads-request', () => { + console.log('Ad request initiated'); + }); + + player.on('ads-load', () => { + console.log('Ad loaded successfully'); + }); + + player.on('ads-start', () => { + console.log('Ad playback started'); + }); + + player.on('ads-end', () => { + console.log('Ad playback ended'); + }); + + player.on('ads-error', (error: any) => { + console.log('Ad error:', error); + }); + playerRef.current = player; } catch (error) { console.error('Failed to initialize Video.js player:', error); diff --git a/replit.md b/replit.md index 2dd2b80..0a95cdb 100644 --- a/replit.md +++ b/replit.md @@ -8,7 +8,7 @@ VideoStream is a fully functional video streaming platform that integrates direc - ✅ **Video.js + VAST Plugin Architecture**: Migrated from HLS.js to Video.js with IMA SDK for professional video streaming and advertising - ✅ **Advanced Video Controls**: Professional video player with fluid responsive design and adaptive streaming -- ✅ **VAST Advertising Support**: Integrated videojs-contrib-ads and videojs-ima for pre-roll, mid-roll, and post-roll video advertisements +- ✅ **VAST Advertising Support**: Integrated videojs-contrib-ads and videojs-ima for pre-roll, mid-roll, and post-roll video advertisements with Google DoubleClick integration - ✅ **Search Functionality**: Client-side search working with proper text visibility (white background, black text) - ✅ **Bunny.net Integration**: Complete integration with private video library using signed URLs for secure access - ✅ **Error Handling**: Robust error handling with Video.js fallback mechanisms