import React, { useState, useEffect, useRef } from 'react'; import { Play, Pause, Volume2, Volume1, VolumeX, Radio, Music, Disc, Zap } from 'lucide-react'; export default function RadioStation() { // State for player const [isPlaying, setIsPlaying] = useState(false); const [volume, setVolume] = useState(80); const [currentTrackIndex, setCurrentTrackIndex] = useState(0); const [elapsed, setElapsed] = useState(0); const [showDJMessage, setShowDJMessage] = useState(false); const [listeners, setListeners] = useState(Math.floor(Math.random() * 1500) + 500); const audioRef = useRef(null); const timerRef = useRef(null); // Playlist data const playlist = [ { title: "Good Days (Disco Remix)", artist: "SZA", genre: "Pop/Disco", duration: 215, coverUrl: "https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17?q=80&w=200&auto=format&fit=crop" }, { title: "Shape of You (Jazz Fusion)", artist: "Ed Sheeran", genre: "Jazz/Pop", duration: 240, coverUrl: "https://images.unsplash.com/photo-1470225620780-dba8ba36b745?q=80&w=200&auto=format&fit=crop" }, { title: "Super Bass (Electronic Remix)", artist: "Nicki Minaj", genre: "Electronic/Hip-Hop", duration: 198, coverUrl: "https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?q=80&w=200&auto=format&fit=crop" }, { title: "Viva La Vida (Mashup)", artist: "Coldplay", genre: "Mashup/Alternative", duration: 225, coverUrl: "https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?q=80&w=200&auto=format&fit=crop" }, { title: "Blinding Lights (Disco Edit)", artist: "The Weeknd", genre: "Disco/Synth-pop", duration: 203, coverUrl: "https://images.unsplash.com/photo-1514525253161-7a46d19cd819?q=80&w=200&auto=format&fit=crop" }, { title: "Levitating (Jazz Club Mix)", artist: "Dua Lipa", genre: "Jazz/Pop", duration: 231, coverUrl: "https://images.unsplash.com/photo-1504509546545-e000b4a62425?q=80&w=200&auto=format&fit=crop" }, { title: "Uptown Funk (Electronic Fusion)", artist: "Mark Ronson ft. Bruno Mars", genre: "Electronic/Funk", duration: 270, coverUrl: "https://images.unsplash.com/photo-1571330735066-03aaa9429d89?q=80&w=200&auto=format&fit=crop" }, { title: "Bad Guy (Remix)", artist: "Billie Eilish", genre: "Electronic/Pop", duration: 194, coverUrl: "https://images.unsplash.com/photo-1598387993281-cecf8b71a8f8?q=80&w=200&auto=format&fit=crop" }, ]; // DJ messages const djMessages = [ "That was a hot track! Keep it locked to Mashup Mix FM 44.7!", "You're listening to the best mashups and remixes on Mashup Mix FM 44.7!", "We're mixing genres and breaking boundaries here on Mashup Mix FM!", "Don't touch that dial! More great music coming up on 44.7 FM!", "Shoutout to all our listeners tuning in from around the world!", "That beat was fire! Up next, we've got another banger for you!" ]; // Simulate audio playback useEffect(() => { if (isPlaying) { timerRef.current = setInterval(() => { setElapsed(prev => { const currentTrack = playlist[currentTrackIndex]; if (prev >= currentTrack.duration) { // Show DJ message between tracks setShowDJMessage(true); setTimeout(() => { setShowDJMessage(false); setCurrentTrackIndex((currentTrackIndex + 1) % playlist.length); setElapsed(0); // Update random listener count setListeners(Math.floor(Math.random() * 1500) + 500); }, 5000); clearInterval(timerRef.current); return prev; } return prev + 1; }); }, 1000); } else { clearInterval(timerRef.current); } return () => clearInterval(timerRef.current); }, [isPlaying, currentTrackIndex, playlist]); // Format time from seconds to MM:SS const formatTime = (seconds) => { const mins = Math.floor(seconds / 60); const secs = seconds % 60; return `${mins}:${secs < 10 ? '0' : ''}${secs}`; }; // Handle play/pause const togglePlay = () => { setIsPlaying(!isPlaying); }; // Handle volume change const handleVolumeChange = (e) => { setVolume(e.target.value); }; // Get volume icon based on level const getVolumeIcon = () => { if (volume === 0) return ; if (volume < 50) return ; return ; }; // Get random DJ message const getRandomDJMessage = () => { return djMessages[Math.floor(Math.random() * djMessages.length)]; }; // Current track const currentTrack = playlist[currentTrackIndex]; // Next few tracks for playlist display const upcomingTracks = []; for (let i = 1; i <= 3; i++) { const index = (currentTrackIndex + i) % playlist.length; upcomingTracks.push(playlist[index]); } return (
{/* Header */}

Mashup Mix FM

44.7

Mixing Genres, Breaking Boundaries

{/* Main content */}
{/* Now Playing Section */}
{/* Album Art */}
{`${currentTrack.title}
{/* Live indicator */}
LIVE
{/* Listeners */}
{listeners.toLocaleString()} listeners
{/* Track Info */}
{showDJMessage ? (

DJ Announcement

{getRandomDJMessage()}

) : ( <>
Now Playing

{currentTrack.title}

{currentTrack.artist}

{currentTrack.genre}
)} {/* Progress bar */}
{formatTime(elapsed)} {formatTime(currentTrack.duration)}
{/* Controls */}
{getVolumeIcon()}
Streaming URL: https://stream.mashupmixfm.com/44.7/live
{/* Visualizer */}
{Array.from({ length: 32 }).map((_, i) => { const height = isPlaying ? Math.floor(Math.random() * 100) + (i % 3 === 0 ? 20 : 10) : 10; return (
); })}
{/* Upcoming tracks */}

Coming Up Next

{upcomingTracks.map((track, index) => (
{`${track.title}

{track.title}

{track.artist}

{track.genre}
))}
{/* Footer */}
); }