Overview
La Urban Radio Player is a single-page web application built with vanilla JavaScript, featuring real-time audio streaming, synchronized lyrics, and advanced audio visualization. The application follows a modular architecture with clear separation of concerns.Technology Stack
Frontend
- Vanilla JavaScript (ES6+)
- HTML5 Audio API
- Web Audio API (for visualization)
- CSS3 with animations
External Services
- Azura Cast (API & Stream)
- Kick.com (Live streaming)
- CBox (Chat integration)
File Structure
Module Loading Order
The modules must load in the following order to ensure proper dependency resolution:Logger System
File: Exports:
js/logger.jsLoaded first to provide logging capabilities to all other modules.window.logger (global instance)Core Modules
1. Logger System (logger.js)
A unified logging system that automatically detects the environment and adjusts verbosity.
Key Features:
- Environment detection (development vs production)
- Multiple log levels:
dev,info,success,warn,error,critical - Production mode silences debug logs
- Development mode shows all logs
2. Cache Manager (cache-manager.js)
Manages API response caching to reduce server load and improve performance.
Key Features:
- Caches API responses for 15 seconds
- Detects significant changes (song changes, live state changes)
- Prevents unnecessary API calls
- Smart update detection
3. Lyrics Manager (lyrics.js)
Manages synchronized lyrics display with adaptive delay for different devices.
Key Features:
- Adaptive stream delay (4.5s for iOS, 1.5s for desktop)
- Virtual time tracking for live streams
- LRC format support
- Smooth fade animations
- Automatic device detection
4. Main Application (index.js)
The core application logic wrapped in an IIFE (Immediately Invoked Function Expression).
Key Components:
Configuration
Application State
Data Flow
Application Initialization
Audio Playback Flow
API Update Cycle
Audio Visualization
Web Audio API Integration
The application uses the Web Audio API for real-time frequency analysis:Frequency Analysis
The visualizer analyzes different frequency ranges:Sub-Bass
20-60 HzKick drum detection
Indices 0-5
Bass
60-250 Hz808s and bass lines
Indices 6-20
Mids
250-2000 HzVocals and melodies
Indices 21-160
High-Mids
2000-4000 HzVocal presence
Indices 161-320
Highs
4000+ HzHi-hats and cymbals
Indices 321+
Kick Detection
AdaptiveThreshold: 0.7
Min time: 150ms
Mobile Optimization
On mobile devices, the visualizer is automatically disabled to avoid CORS issues and improve performance:Event Handling
DOM Events
Audio Events
Performance Optimizations
GPU Acceleration
All animations usetranslate3d for GPU acceleration:
Throttling and Debouncing
- API Updates: 5-second intervals with caching
- Lyrics Updates: 100ms intervals
- Visualizer: 60 FPS via
requestAnimationFrame
Lazy Loading
- iframes loaded on-demand
- Covers preloaded before transition
- Audio source lazy-initialized
Error Handling
Browser Extension Errors
The application suppresses common browser extension errors:Audio Playback Errors
State Management
State is managed through a centralstate object with reactive updates:
Next Steps
- Learn about Mobile Optimization techniques
- Review Setup Guide for local development
- Explore CORS Setup and Streaming Configuration
