import { useState, useEffect, useRef } from 'react'; import { ChevronLeft, Maximize, Volume2, VolumeX, Radio } from 'lucide-react'; import { Link } from 'wouter'; import { Button } from '@/components/ui/button'; import AdSenseAd from '@/components/adsense-ad'; declare global { interface Window { Hls: any; } } export default function LivePage() { const videoRef = useRef(null); const hlsRef = useRef(null); const [isLoading, setIsLoading] = useState(true); const [isPlaying, setIsPlaying] = useState(false); const [volume, setVolume] = useState(1); const [isMuted, setIsMuted] = useState(false); const [error, setError] = useState(null); // HLS stream URL const streamUrl = 'https://cdne.folxplay.tv/fxt/streams/ch-4/master.m3u8'; useEffect(() => { // Set page meta tags document.title = 'LIVE Stream | video.folx.tv'; const metaDescription = document.querySelector('meta[name="description"]'); if (metaDescription) { metaDescription.setAttribute('content', 'Živý prenos na video.folx.tv - sledujte exkluzívny obsah v reálnom čase.'); } const updateMetaTag = (property: string, content: string) => { let meta = document.querySelector(`meta[property="${property}"]`); if (!meta) { meta = document.createElement('meta'); meta.setAttribute('property', property); document.head.appendChild(meta); } meta.setAttribute('content', content); }; updateMetaTag('og:title', 'LIVE Stream - video.folx.tv'); updateMetaTag('og:description', 'Živý prenos na video.folx.tv - sledujte exkluzívny obsah v reálnom čase.'); updateMetaTag('og:type', 'video.other'); }, []); useEffect(() => { const initializePlayer = async () => { console.log('🔴 LivePage: Starting to initialize player...'); if (!videoRef.current) { console.error('🚨 Video ref not available!'); return; } console.log('🔴 Video element found, continuing...'); try { // Load HLS.js if not already loaded console.log('🔴 Checking if HLS.js is loaded...'); if (!window.Hls) { console.log('🔴 Loading HLS.js script...'); const script = document.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/hls.js@1.5.8'; script.async = true; document.head.appendChild(script); await new Promise((resolve, reject) => { script.onload = () => { console.log('✅ HLS.js script loaded successfully'); resolve(null); }; script.onerror = (e) => { console.error('❌ Failed to load HLS.js script:', e); reject(e); }; }); } else { console.log('✅ HLS.js already available'); } const video = videoRef.current; console.log('🔴 Stream URL:', streamUrl); if (window.Hls && window.Hls.isSupported()) { console.log('🔴 HLS.js is supported, initializing...'); const hls = new window.Hls({ debug: true, enableWorker: false, lowLatencyMode: true, backBufferLength: 90, maxBufferLength: 30, maxMaxBufferLength: 600, maxBufferSize: 60 * 1000 * 1000, maxBufferHole: 0.5 }); console.log('🔴 Loading source:', streamUrl); hls.loadSource(streamUrl); hls.attachMedia(video); hls.on(window.Hls.Events.MEDIA_ATTACHED, () => { console.log('✅ HLS media attached successfully'); }); hls.on(window.Hls.Events.MANIFEST_PARSED, (event: any, data: any) => { console.log('✅ HLS manifest parsed successfully:', data); console.log('Available levels:', data.levels); setIsLoading(false); // Try auto-play video.play().then(() => { console.log('✅ Auto-play started successfully'); }).catch((e) => { console.log('⚠️ Auto-play blocked, user interaction required:', e); setError('Kliknite play za zagon streama'); }); }); hls.on(window.Hls.Events.LEVEL_LOADED, (event: any, data: any) => { console.log('📊 Level loaded:', data); }); hls.on(window.Hls.Events.FRAG_LOADED, (event: any, data: any) => { console.log('📦 Fragment loaded:', data.frag.url); }); hls.on(window.Hls.Events.ERROR, (event: any, data: any) => { console.error('🚨 HLS Error occurred:', { type: data.type, details: data.details, fatal: data.fatal, error: data.error, event, data }); if (data.fatal) { switch (data.type) { case window.Hls.ErrorTypes.NETWORK_ERROR: console.log('🔄 Network error, attempting recovery...'); setError('Napaka pri povezavi s streamom - poskušam znova...'); hls.startLoad(); break; case window.Hls.ErrorTypes.MEDIA_ERROR: console.log('🔄 Media error, attempting recovery...'); setError('Napaka pri predvajanju - poskušam znova...'); hls.recoverMediaError(); break; default: console.error('💥 Fatal error, cannot recover:', data); setError(`Napaka pri streamingu: ${data.details}`); break; } } }); hlsRef.current = hls; } else if (video.canPlayType('application/vnd.apple.mpegurl')) { // Native HLS support (Safari) console.log('🍎 Using native HLS support (Safari)'); video.src = streamUrl; video.addEventListener('loadedmetadata', () => { console.log('✅ Native HLS metadata loaded'); setIsLoading(false); }); video.addEventListener('error', (e) => { console.error('❌ Native video error:', e); setError('Napaka pri nalaganju streama'); }); } else { console.error('❌ HLS not supported in this browser'); setError('HLS ni podprt v tem brskalniku'); setIsLoading(false); } // Add comprehensive video event listeners video.addEventListener('play', () => { console.log('▶️ Video started playing'); setIsPlaying(true); }); video.addEventListener('pause', () => { console.log('⏸️ Video paused'); setIsPlaying(false); }); video.addEventListener('volumechange', () => { setVolume(video.volume); setIsMuted(video.muted); }); video.addEventListener('loadstart', () => { console.log('🔄 Video load started'); }); video.addEventListener('loadeddata', () => { console.log('📊 Video data loaded'); }); video.addEventListener('canplay', () => { console.log('✅ Video can start playing'); }); video.addEventListener('error', (e) => { console.error('❌ Video element error:', e); setError('Napaka video elementa'); }); } catch (error) { console.error('💥 Failed to initialize live stream player:', error); setError('Napaka pri inicializaciji playerja'); setIsLoading(false); } }; // Add a small delay to ensure DOM is ready const timer = setTimeout(() => { initializePlayer(); }, 200); return () => { clearTimeout(timer); if (hlsRef.current) { console.log('🧹 Destroying HLS instance'); hlsRef.current.destroy(); } }; }, []); const togglePlayPause = () => { if (videoRef.current) { if (isPlaying) { videoRef.current.pause(); } else { videoRef.current.play().catch((e) => { console.log('Play failed:', e); setError('Napaka pri predvajanju'); }); } } }; const toggleMute = () => { if (videoRef.current) { videoRef.current.muted = !isMuted; } }; const toggleFullscreen = () => { if (videoRef.current) { if (videoRef.current.requestFullscreen) { videoRef.current.requestFullscreen(); } } }; if (isLoading) { return (

video.folx.tv

Connecting to live stream...

); } return (
{/* Header */}
LIVE
{/* Main Video Player */}
{error && (

Stream Error

{error}

)}
{/* Stream Info */}

FOLX TV Live Stream

Sledujte živý prenos FOLX TV s exkluzívnym obsahom a najnovšími videoami. Stream prebieha 24/7 s najlepšími hitmi a videoklipmi.

Live Stream Channel 4 HD Quality
{/* Sidebar */}
{/* Ad Space */}
{/* Live Chat or Additional Content */}

Live Info

Status: ● LIVE
Quality: Auto (HD)
Channel: CH-4
Format: HLS
{/* Navigation Links */}

Explore

← Back to Home FOLX STADL Episodes Geschichte des Liedes Gipfelstammtisch
); }