Skip to content

BrainAV/Radio-Stream-Player-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ“» Radio Stream Player

A self-hosted, full-stack internet radio player with user accounts, audio visualizations, and a Glassmorphism UI.

License Version Last Commit Issues Stars

πŸ”΄ Live Demo β€” radio.djay.ca

[!NOTE] The live demo uses a Cloudflare Worker proxy (api.djay.ca) to tunnel legacy HTTP streams over HTTPS and extract real-time ICY metadata without browser security warnings.


✨ Feature Highlights

🎡 Player & Audio

Feature Description
7 VU Meter Styles Classic Bars, LED, Circular, Waveform, Spectrum, Retro Needle, Neon Glow
Live Metadata Real-time "Now Playing" track & artist info via ICY metadata polling
Media Keys OS lock screen integration + hardware Play/Pause/Next/Prev support
Pop-out Player Compact floating window β€” syncs background, station list, and filters from the main player. Auto-starts playback.
Streaming Proxy Routes http:// streams through a secure proxy, eliminating Mixed Content warnings

πŸ‘€ User Accounts & Personalization

Feature Description
AJAX Auth Login/register/logout without stopping playback or reloading the page
Cloud Favorites Favorites and custom stations sync to your account via the PHP/MySQL backend
Custom Backgrounds Set any image URL as your wallpaper or choose from curated presets
Light & Dark Themes Auto-detects system preference; manually toggleable
Genre & Favorites Filter Filter your station list by genre or show favorites only β€” persists across sessions

πŸ” Station Discovery

Feature Description
Radio Browser API Search 30,000+ community-driven stations by name, tag, or country
Custom Stations Add and manage your own private stream URLs
Add to Favorites One-click add from search results to your personal library

πŸ›‘οΈ Admin Dashboard

Feature Description
User Management Edit roles, toggle premium status, ban or delete users
Site Config Manage Google Tag (GA4), AdSense ID, and custom head scripts from a UI
Premium Tier Mark users as premium to suppress ads server-side
Role-Based Ads AdSense automatically disabled for admin and is_premium users β€” no refresh required

πŸ—οΈ Architecture Overview

Browser (Vanilla JS + Web Audio API)
    β”‚
    β”œβ”€β”€ player.js       β€” Core player state, playback engine, pub/sub StateManager
    β”œβ”€β”€ settings.js     β€” Auth modals, user settings, favorites, genre filters
    β”œβ”€β”€ visualizer.js   β€” 7 VU meter styles via Web Audio API AnalyserNode
    └── api.js          β€” Fetch wrappers for all PHP API endpoints
          β”‚
          β–Ό
PHP / MySQL Backend (LAMP/LEMP)
    β”‚
    β”œβ”€β”€ index.php           β€” Entry point; injects session data, ad scripts, user role
    β”œβ”€β”€ popout.php          β€” Pop-out entry point; same server-side ad injection pattern
    β”œβ”€β”€ api/auth.php        β€” AJAX login / logout / session management
    β”œβ”€β”€ api/favorites.php   β€” User favorites CRUD
    β”œβ”€β”€ api/stations.php    β€” Default & custom station management
    β”œβ”€β”€ api/admin/          β€” Admin-only endpoints (users, settings)
    └── database/schema.sql β€” Full MySQL schema
          β”‚
          β–Ό
Cloudflare Worker (api.djay.ca) β€” optional, for demo/HTTPS deployment
    β”œβ”€β”€ Audio proxy     β€” Tunnels http:// streams over HTTPS
    └── ICY metadata    β€” Extracts Now Playing info from stream headers

πŸ› οΈ Tech Stack

Layer Technology
Backend PHP 8.x, PDO/MySQL
Database MySQL 5.7+ / MariaDB
Frontend Vanilla JavaScript (ES6+), HTML5, CSS3
Audio Web Audio API (AnalyserNode, GainNode)
Auth PHP Sessions + AJAX (no JWT, no framework)
Proxy Cloudflare Workers (optional, for demo)
Directory Radio Browser API

πŸš€ Installation

Prerequisites

  • PHP 8.0+
  • MySQL 5.7+ or MariaDB
  • A standard LAMP / LEMP web server (Apache or Nginx)
  • cPanel-compatible hosting or a VPS β€” this is a standard PHP project, no Composer/Node required

Setup

1. Clone the repository

git clone https://github.com/BrainAV/Radio-Stream-Player-PHP.git .

2. Database

# Create a MySQL database and user, then import the schema:
mysql -u youruser -p yourdb < database/schema.sql

3. Configure credentials

Copy and edit the config file:

cp api/config.example.php api/config.php

Then set your DB host, name, username, and password in api/config.php.

4. Deploy

Upload to your web root. index.php is the entry point β€” no .htaccess rewrites required for basic usage.

5. First-time Admin Setup

After deploying, register a user account, then manually set role = 'admin' in the users table:

UPDATE users SET role = 'admin' WHERE user_email = 'you@example.com';

Then access the Admin Dashboard at /admin.php.

Optional: Upgrade from v2.1.x

Run the migration script to add monetization tables:

source database/update_v2.2_monetization.sql

Local Development (no PHP)

To test the frontend UI only:

python -m http.server 8000
# Then open http://localhost:8000

Account features, favorites, and admin require a live PHP/MySQL environment.


πŸ“ Project Structure

Radio-Stream-Player-PHP/
β”œβ”€β”€ index.php               # Main entry point (serves template-player.html with session data)
β”œβ”€β”€ popout.php              # Pop-out window entry point
β”œβ”€β”€ admin.php               # Admin dashboard entry point
β”œβ”€β”€ template-player.html    # Main player HTML template
β”œβ”€β”€ popout.html             # Pop-out player HTML
β”œβ”€β”€ styles.css              # All styles β€” Glassmorphism design system
β”‚
β”œβ”€β”€ player.js               # Core player: audio engine, StateManager, media keys
β”œβ”€β”€ settings.js             # Settings modal: auth, favorites, custom stations, filters
β”œβ”€β”€ visualizer.js           # Web Audio API VU meter (7 styles)
β”œβ”€β”€ api.js                  # Frontend fetch wrappers
β”œβ”€β”€ admin.js                # Admin dashboard logic
β”œβ”€β”€ popout-script.js        # Pop-out player logic
β”‚
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ config.php          # DB credentials (not committed β€” add to .gitignore)
β”‚   β”œβ”€β”€ auth.php            # Login/logout AJAX handler
β”‚   β”œβ”€β”€ favorites.php       # Favorites CRUD
β”‚   β”œβ”€β”€ stations.php        # Station management
β”‚   β”œβ”€β”€ register.php        # User registration
β”‚   └── admin/
β”‚       β”œβ”€β”€ users.php       # Admin: user management
β”‚       └── settings.php    # Admin: site config (GA4, AdSense, custom scripts)
β”‚
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ schema.sql                      # Full MySQL schema (fresh install)
β”‚   └── update_v2.2_monetization.sql    # Migration: adds is_premium, site_config table
β”‚
└── docs/
    β”œβ”€β”€ DEVELOPER_GUIDE.md      # Architecture & contribution guide
    β”œβ”€β”€ RELEASE_v2.2.0.md       # Release notes
    └── UNSPLASH_GUIDE.md       # Background image formatting guide

⌨️ Keyboard Shortcuts

Key Action
Space / Play/Pause Media Key Toggle playback
Next Track Media Key Next station
Prev Track Media Key Previous station
Tab Navigate all controls

πŸ“‹ Changelog

See CHANGELOG.md for the full version history.

Latest: v2.2.0 β€” Monetization & Pop-out Evolution


🀝 Contributing

Issues and PRs are welcome. For significant changes, please open an issue first to discuss the approach.


Built by the BrainAV team Β β€’Β  Live Demo Β β€’Β  Changelog Β β€’Β  Roadmap

About

A self-hosted internet radio player with PHP/MySQL backend, user accounts, audio visualizations, pop-out player, and AdSense monetization support.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors