diff --git a/README.md b/README.md index ba82c2d..c6a4875 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It supports: - Local library playback (files in `music/`) - Downloading audio from URLs (via `yt-dlp` when available, with fallback) - Live streaming from the DJ browser to listeners using Socket.IO -- **Compatibility fallback**: if a listener browser can’t play the WebM/Opus stream, it can fall back to an **MP3 stream** (`/stream.mp3`) generated server-side with **ffmpeg**. +- Live listening via an **MP3 stream** (`/stream.mp3`) generated server-side with **ffmpeg**. --- @@ -161,22 +161,13 @@ If listeners can’t connect, this is often the cause. --- -## Streaming formats & fallback +## Streaming -### Default stream - -- DJ browser encodes live audio using `MediaRecorder` (usually WebM/Opus) -- Listeners receive chunks over Socket.IO and play them via MediaSource - -### MP3 fallback (compatibility) - -Some browsers/environments don’t support WebM/Opus + MediaSource well. -In that case TechDJ can fall back to: +TechDJ serves the listener audio as an **MP3 HTTP stream**: - MP3 stream endpoint: `http://:5001/stream.mp3` -This requires: -- `ffmpeg` installed on the DJ/server machine +This requires `ffmpeg` installed on the DJ/server machine. ### Debug endpoint diff --git a/script.js b/script.js index f1e9ad9..2263aae 100644 --- a/script.js +++ b/script.js @@ -1848,11 +1848,12 @@ function startBroadcast() { console.log(`🎚️ Starting broadcast at ${qualitySelect.value}kbps`); const preferredTypes = [ - 'audio/webm;codecs=opus', - 'audio/webm', - 'audio/ogg;codecs=opus', + // Prefer MP4/AAC when available (broad device support) 'audio/mp4;codecs=mp4a.40.2', 'audio/mp4', + // Fallbacks + 'audio/webm', + 'audio/ogg', ]; const chosenType = preferredTypes.find((t) => { try { @@ -1993,9 +1994,9 @@ function startBroadcast() { document.getElementById('broadcast-status').textContent = 'πŸ”΄ LIVE'; document.getElementById('broadcast-status').classList.add('live'); - // Notify server (include codec/container so listeners can configure SourceBuffer) + // Notify server that broadcast is active (listeners use MP3 stream) if (!socket) initSocket(); - socket.emit('start_broadcast', { mimeType: currentStreamMimeType }); + socket.emit('start_broadcast'); socket.emit('get_listener_count'); console.log('βœ… Broadcasting started successfully!'); @@ -2153,7 +2154,7 @@ function toggleAutoStream(enabled) { // ========== LISTENER MODE ========== function initListenerMode() { - console.log('🎧 Initializing listener mode (MediaSource Pipeline)...'); + console.log('🎧 Initializing listener mode (MP3 stream)...'); // UI Feedback for listener const appContainer = document.querySelector('.app-container'); @@ -2224,8 +2225,8 @@ function initListenerMode() { } // Create a new hidden media element. - // Note: MSE (MediaSource) support is often more reliable on