Compare commits

..

No commits in common. "4ec90c0f273213be3622ccd6441e8f5969ed9a06" and "924f6498de25e391abde773c22143c315f3e8cd6" have entirely different histories.

23 changed files with 57 additions and 343 deletions

View File

@ -1,4 +1,4 @@
** [#C] Rundown to Launch. Still to do: * Rundown to Launch. Still to do:
* Setup asteroid.radio server at Hetzner [7/7] * Setup asteroid.radio server at Hetzner [7/7]
- [X] Provision a VPS - [X] Provision a VPS
@ -25,23 +25,23 @@
1) [X] Liquidsoap is exposing its management console via telnet on the exterior network interface of b612.asteroid.radio 1) [X] Liquidsoap is exposing its management console via telnet on the exterior network interface of b612.asteroid.radio
2) [X] icecast is also binding the external interface on b612, which it 2) [X] icecast is also binding the external interface on b612, which it
should not be. HAproxy is there to mediate this flow. should not be. HAproxy is there to mediate this flow.
3) [X] We're still on the built in i-lambdalite database 3) [ ] We're still on the built in i-lambdalite database
4) [X] The templates still advertise the default administrator password, 4) [X] The templates still advertise the default administrator password,
which is no bueno. which is no bueno.
5) [X] We need to work out the TLS situation with letsencrypt, and 5) [ ] We need to work out the TLS situation with letsencrypt, and
integrate it into HAproxy. integrate it into HAproxy.
6) [ ] The administrative interface should be beefed up. 6) [ ] The administrative interface should be beefed up.
6.1) [X] Deactivate users 6.1) [ ] Deactivate users
6.2) [X] Change user access permissions 6.2) [ ] Change user access permissions
6.3) [ ] Listener statistics, breakdown by day/hour, new users, % changed &c 6.3) [ ] Listener statistics, breakdown by day/hour, new users, % changed &c
7) [ ] When the player is paused, there are pretty serious stream sync issues in the form of stuttering for some time after the stream is unpaused. 7) [ ] When the player is paused, there are pretty serious stream sync issues in the form of stuttering for some time after the stream is unpaused.
8) [ ] User profile pages should probably be fleshed out. 8) [ ] User profile pages should probably be fleshed out.
9) [ ] the stream management features aren't there for Admins or DJs. 9) [ ] the stream management features aren't there for Admins or DJs.
10) [X] The "Scan Library" feature is not working in the main branch 10) [ ] The "Scan Library" feature is not working in the main branch
11) [X] The player widget should be styled so it fits the site theme on systems running 'light' thmes. 11) [ ] The player widget should be styled so it fits the site theme on systems running 'light' thmes.
12) [X] ensure each info field 'Listeners: ..' &c has only one instance per page. 12) [ ] ensure each info field 'Listeners: ..' &c has only one instance per page.
* Server runtime configuration [0/1] * Server runtime configuration [0/1]
- [ ] parameterize all configuration for runtime loading [0/2] - [ ] parameterize all configuration for runtime loading [0/2]

View File

@ -41,8 +41,7 @@
(:file "conditions") (:file "conditions")
(:file "database") (:file "database")
(:file "template-utils") (:file "template-utils")
(:module :parenscript (:file "spectrum-analyzer")
:components ((:file "spectrum-analyzer")))
(:file "stream-media") (:file "stream-media")
(:file "user-management") (:file "user-management")
(:file "playlist-management") (:file "playlist-management")

View File

@ -10,8 +10,7 @@
<header-timeout>15</header-timeout> <header-timeout>15</header-timeout>
<source-timeout>10</source-timeout> <source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect> <burst-on-connect>1</burst-on-connect>
<!-- Reduced from 65535 to minimize buffer accumulation during pause --> <burst-size>65535</burst-size>
<burst-size>8192</burst-size>
</limits> </limits>
<authentication> <authentication>

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - API Endpoints Reference #+TITLE: Asteroid Radio - API Endpoints Reference
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - API Reference #+TITLE: Asteroid Radio - API Reference
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Current Interfaces * Current Interfaces

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - Development Guide #+TITLE: Asteroid Radio - Development Guide
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Development Setup * Development Setup

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - Docker Streaming Setup #+TITLE: Asteroid Radio - Docker Streaming Setup
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Docker Streaming Overview * Docker Streaming Overview

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - Installation Guide #+TITLE: Asteroid Radio - Installation Guide
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Installation Overview * Installation Overview

View File

@ -1,6 +1,6 @@
#+TITLE: Playlist System - Complete (MVP) #+TITLE: Playlist System - Complete (MVP)
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -1,6 +1,6 @@
#+TITLE: PostgreSQL Setup for Asteroid Radio #+TITLE: PostgreSQL Setup for Asteroid Radio
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - Project Development History #+TITLE: Asteroid Radio - Project Development History
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
#+DESCRIPTION: Comprehensive history of the Asteroid Radio project from inception to present #+DESCRIPTION: Comprehensive history of the Asteroid Radio project from inception to present
* Project Overview * Project Overview
@ -11,8 +11,7 @@ Asteroid Radio is a web-based internet radio station built with Common Lisp, fea
- *Backend*: Common Lisp (SBCL), Radiance web framework - *Backend*: Common Lisp (SBCL), Radiance web framework
- *Streaming*: Icecast2, Liquidsoap - *Streaming*: Icecast2, Liquidsoap
- *Database*: PostgreSQL (configured, ready for migration) - *Database*: PostgreSQL (configured, ready for migration)
- *Frontend*: HTML5, JavaScript, Parenscript, CLIP templating, LASS (CSS in Lisp) - *Frontend*: HTML5, JavaScript, CLIP templating, LASS (CSS in Lisp)
- *Audio Visualization*: Web Audio API, Canvas
- *Infrastructure*: Docker, Docker Compose - *Infrastructure*: Docker, Docker Compose
* Project Timeline * Project Timeline
@ -232,43 +231,19 @@ Asteroid Radio is a web-based internet radio station built with Common Lisp, fea
- Synchronized with upstream/main - Synchronized with upstream/main
- Prepared comprehensive documentation PR - Prepared comprehensive documentation PR
** Phase 9: Visual Audio Features (December 2025)
*** 2025-12-06: Real-Time Spectrum Analyzer
- *Lead*: Brian O'Reilly (Fade), Glenn Thompson
- Implemented spectrum analyzer using Parenscript
- Web Audio API integration for real-time visualization
- Dynamic JavaScript generation via API endpoint
- Canvas-based frequency display
- Works across all player modes (inline, pop-out, frameset)
- Lisp-to-JavaScript compilation for maintainability
* Development Statistics * Development Statistics
** Contributors (by commit count) ** Contributors (by commit count)
1. Glenn Thompson (glenneth/Glenneth) - 236 commits 1. Glenn Thompson (glenneth/Glenneth) - 135+ commits
2. Brian O'Reilly (Fade) - 109 commits 2. Brian O'Reilly (Fade) - 55+ commits
3. Luis Pereira (easilok) - 63 commits 3. Luis Pereira (easilok) - 23+ commits
** Total Commits: 408 commits ** Total Commits: 213+ commits
** Code Statistics
- *Total Lines of Code*: ~9,300 lines
- *Common Lisp*: 2,753 lines (.lisp, .asd)
- *JavaScript*: 2,315 lines (.js)
- *Templates*: 1,505 lines (.ctml)
- *Other*: 2,720 lines (CSS, Shell, Python, etc.)
- *Source Files*: 50 files
** Release Information
- *Current Version*: Development (pre-1.0)
- *Tagged Releases*: None (continuous development)
- *Deployment Status*: Production-ready
** Active Development Period ** Active Development Period
- Start: August 12, 2025 - Start: August 12, 2025
- Current: December 6, 2025 - Current: November 1, 2025
- Duration: ~4 months of active development - Duration: ~2.75 months of active development
* Major Features Implemented * Major Features Implemented
@ -291,7 +266,6 @@ Asteroid Radio is a web-based internet radio station built with Common Lisp, fea
- ✅ Multiple quality options (AAC 96k, MP3 128k, MP3 64k) - ✅ Multiple quality options (AAC 96k, MP3 128k, MP3 64k)
- ✅ ReplayGain volume normalization - ✅ ReplayGain volume normalization
- ✅ Live now-playing information - ✅ Live now-playing information
- ✅ Real-time spectrum analyzer visualization
- ✅ Icecast integration - ✅ Icecast integration
- ✅ Liquidsoap DJ controls - ✅ Liquidsoap DJ controls
- ✅ Stream queue management - ✅ Stream queue management
@ -351,7 +325,7 @@ Asteroid Radio is a web-based internet radio station built with Common Lisp, fea
- Parallel music scanning - Parallel music scanning
- Client-side caching - Client-side caching
* Current State (December 2025) * Current State (November 2025)
** Production Ready Features ** Production Ready Features
- Full music streaming platform - Full music streaming platform
@ -359,7 +333,6 @@ Asteroid Radio is a web-based internet radio station built with Common Lisp, fea
- Admin control panel - Admin control panel
- DJ controls - DJ controls
- Multiple player modes - Multiple player modes
- Real-time spectrum analyzer
- Complete Docker deployment (streams + application) - Complete Docker deployment (streams + application)
- Multi-environment support with dynamic URLs - Multi-environment support with dynamic URLs
- Comprehensive documentation - Comprehensive documentation
@ -419,9 +392,9 @@ Asteroid Radio is a web-based internet radio station built with Common Lisp, fea
* Conclusion * Conclusion
Asteroid Radio has evolved from a simple concept into a full-featured internet radio platform in just 4 months of active development. The project demonstrates the power of Common Lisp for web development and the collaborative nature of open-source development. Asteroid Radio has evolved from a simple concept into a full-featured internet radio platform in just 2.75 months of active development. The project demonstrates the power of Common Lisp for web development and the collaborative nature of open-source development.
With complete Docker deployment, real-time audio visualization, comprehensive documentation, and a growing feature set, Asteroid Radio is ready for production use while continuing to evolve with regular improvements, bug fixes, and new features based on user needs and technical requirements. With complete Docker deployment, comprehensive documentation, and a growing feature set, Asteroid Radio is ready for production use while continuing to evolve with regular improvements, bug fixes, and new features based on user needs and technical requirements.
** Project Links ** Project Links
- Repository: https://github.com/fade/asteroid - Repository: https://github.com/fade/asteroid
@ -430,4 +403,4 @@ With complete Docker deployment, real-time audio visualization, comprehensive do
--- ---
*Last Updated: 2025-12-06* *Last Updated: 2025-11-01*

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio - Project Overview #+TITLE: Asteroid Radio - Project Overview
#+AUTHOR: Glenn Thompson & Brian O'Reilly (Fade) #+AUTHOR: Glenn Thompson & Brian O'Reilly (Fade)
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* 🎯 Mission * 🎯 Mission
@ -45,8 +45,6 @@ Asteroid Radio is a modern, web-based music streaming platform designed for hack
- **HTML5** with semantic templates - **HTML5** with semantic templates
- **CSS3** with dark hacker theme - **CSS3** with dark hacker theme
- **JavaScript** for interactive features - **JavaScript** for interactive features
- **Parenscript** - Lisp-to-JavaScript compiler for spectrum analyzer
- **Web Audio API** - Real-time audio visualization
- **VT323 Font** for retro terminal aesthetic - **VT323 Font** for retro terminal aesthetic
**Streaming:** **Streaming:**
@ -83,7 +81,6 @@ Asteroid Radio is a modern, web-based music streaming platform designed for hack
- ✅ **Music Library** - Track management with pagination, search, and filtering - ✅ **Music Library** - Track management with pagination, search, and filtering
- ✅ **User Playlists** - Create, manage, and play personal music collections - ✅ **User Playlists** - Create, manage, and play personal music collections
- ✅ **Multiple Player Modes** - Inline, pop-out, and persistent frameset players - ✅ **Multiple Player Modes** - Inline, pop-out, and persistent frameset players
- ✅ **Real-Time Spectrum Analyzer** - Visual audio frequency display using Web Audio API and Parenscript
- ✅ **Stream Queue Control** - Admin control over broadcast stream queue (M3U-based) - ✅ **Stream Queue Control** - Admin control over broadcast stream queue (M3U-based)
- ✅ **REST API** - Comprehensive JSON API with 15+ endpoints - ✅ **REST API** - Comprehensive JSON API with 15+ endpoints
- ✅ **Music Streaming** - Multiple quality formats (128k MP3, 96k AAC, 64k MP3) - ✅ **Music Streaming** - Multiple quality formats (128k MP3, 96k AAC, 64k MP3)

View File

@ -65,7 +65,6 @@ Pagination system for efficient browsing of large music libraries.
- **Music Library**: Track management with pagination, search, and filtering - **Music Library**: Track management with pagination, search, and filtering
- **Playlists**: User playlists with creation and playback - **Playlists**: User playlists with creation and playback
- **Multiple Player Modes**: Inline, pop-out, and persistent frameset players - **Multiple Player Modes**: Inline, pop-out, and persistent frameset players
- **Real-Time Spectrum Analyzer**: Visual audio frequency display using Web Audio API
- **Stream Queue Control**: Admin control over broadcast stream queue - **Stream Queue Control**: Admin control over broadcast stream queue
- **Docker Streaming Infrastructure**: Icecast2 + Liquidsoap containers - **Docker Streaming Infrastructure**: Icecast2 + Liquidsoap containers
- **Three Quality Streams**: 128kbps MP3, 96kbps AAC, 64kbps MP3 - **Three Quality Streams**: 128kbps MP3, 96kbps AAC, 64kbps MP3
@ -148,5 +147,5 @@ For detailed technical information, see the **[[file:PROJECT-OVERVIEW.org][Proje
--- ---
*Last Updated: 2025-12-06* *Last Updated: 2025-10-26*
*Documentation Version: 3.1* *Documentation Version: 3.0*

View File

@ -1,6 +1,6 @@
#+TITLE: Stream Queue Control System #+TITLE: Stream Queue Control System
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -1,6 +1,6 @@
#+TITLE: Asteroid Radio Testing Guide #+TITLE: Asteroid Radio Testing Guide
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -1,6 +1,6 @@
#+TITLE: Track Pagination System - Complete #+TITLE: Track Pagination System - Complete
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -1,6 +1,6 @@
#+TITLE: User Management System - Complete #+TITLE: User Management System - Complete
#+AUTHOR: Asteroid Radio Development Team #+AUTHOR: Asteroid Radio Development Team
#+DATE: 2025-12-06 #+DATE: 2025-10-26
* Overview * Overview

View File

@ -12,18 +12,6 @@
(defvar *canvas* nil) (defvar *canvas* nil)
(defvar *canvas-ctx* nil) (defvar *canvas-ctx* nil)
(defvar *animation-id* nil) (defvar *animation-id* nil)
(defvar *media-source* nil)
(defvar *current-audio-element* nil)
(defun reset-spectrum-analyzer ()
"Reset the spectrum analyzer to allow reconnection after audio element reload"
(when *animation-id*
(cancel-animation-frame *animation-id*)
(setf *animation-id* nil))
(setf *audio-context* nil)
(setf *analyser* nil)
(setf *media-source* nil)
(ps:chain console (log "Spectrum analyzer reset for reconnection")))
(defun init-spectrum-analyzer () (defun init-spectrum-analyzer ()
"Initialize the spectrum analyzer" "Initialize the spectrum analyzer"
@ -49,35 +37,27 @@
(:catch (e) (:catch (e)
(ps:chain console (log "Cross-frame access error:" e))))) (ps:chain console (log "Cross-frame access error:" e)))))
(when (and audio-element canvas-element) (when (and audio-element canvas-element (not *audio-context*))
;; Store current audio element ;; Create Audio Context
(setf *current-audio-element* audio-element) (setf *audio-context* (ps:new (or (ps:@ window |AudioContext|)
(ps:@ window |webkitAudioContext|))))
;; Only create audio context and media source once ;; Create Analyser Node
(when (not *audio-context*) (setf *analyser* (ps:chain *audio-context* (create-analyser)))
;; Create Audio Context (setf (ps:@ *analyser* |fftSize|) 256)
(setf *audio-context* (ps:new (or (ps:@ window |AudioContext|) (setf (ps:@ *analyser* |smoothingTimeConstant|) 0.8)
(ps:@ window |webkitAudioContext|))))
;; Connect audio source to analyser
;; Create Analyser Node (let ((source (ps:chain *audio-context* (create-media-element-source audio-element))))
(setf *analyser* (ps:chain *audio-context* (create-analyser))) (ps:chain source (connect *analyser*))
(setf (ps:@ *analyser* |fftSize|) 256) (ps:chain *analyser* (connect (ps:@ *audio-context* destination))))
(setf (ps:@ *analyser* |smoothingTimeConstant|) 0.8)
;; Connect audio source to analyser (can only be done once per element)
(setf *media-source* (ps:chain *audio-context* (create-media-element-source audio-element)))
(ps:chain *media-source* (connect *analyser*))
(ps:chain *analyser* (connect (ps:@ *audio-context* destination)))
(ps:chain console (log "Spectrum analyzer audio context created")))
;; Setup canvas ;; Setup canvas
(setf *canvas* canvas-element) (setf *canvas* canvas-element)
(setf *canvas-ctx* (ps:chain *canvas* (get-context "2d"))) (setf *canvas-ctx* (ps:chain *canvas* (get-context "2d")))
;; Start visualization if not already running ;; Start visualization
(when (not *animation-id*) (draw-spectrum))))
(draw-spectrum)))))
(defun draw-spectrum () (defun draw-spectrum ()
"Draw the spectrum analyzer visualization" "Draw the spectrum analyzer visualization"

View File

@ -635,12 +635,6 @@ function displayQueueSearchResults(results) {
// Live stream info update // Live stream info update
async function updateLiveStreamInfo() { async function updateLiveStreamInfo() {
// Don't update if stream is paused
const audioElement = document.getElementById('live-stream-audio');
if (audioElement && audioElement.paused) {
return;
}
try { try {
const response = await fetch('/api/asteroid/partial/now-playing-inline'); const response = await fetch('/api/asteroid/partial/now-playing-inline');
const contentType = response.headers.get("content-type"); const contentType = response.headers.get("content-type");

View File

@ -55,12 +55,6 @@ function changeStreamQuality() {
// Update now playing info from Icecast // Update now playing info from Icecast
async function updateNowPlaying() { async function updateNowPlaying() {
// Don't update if stream is paused
const audioElement = document.getElementById('live-audio');
if (audioElement && audioElement.paused) {
return;
}
try { try {
const response = await fetch('/api/asteroid/partial/now-playing') const response = await fetch('/api/asteroid/partial/now-playing')
const contentType = response.headers.get("content-type") const contentType = response.headers.get("content-type")
@ -108,60 +102,9 @@ window.addEventListener('DOMContentLoaded', function() {
// Update playing information right after load // Update playing information right after load
updateNowPlaying(); updateNowPlaying();
// Auto-reconnect on stream errors and after long pauses // Auto-reconnect on stream errors
const audioElement = document.getElementById('live-audio'); const audioElement = document.getElementById('live-audio');
if (audioElement) { if (audioElement) {
// Track pause timestamp to detect long pauses and reconnect
let pauseTimestamp = null;
let isReconnecting = false;
let needsReconnect = false;
const PAUSE_RECONNECT_THRESHOLD = 10000; // 10 seconds
audioElement.addEventListener('pause', function() {
pauseTimestamp = Date.now();
console.log('Stream paused at:', pauseTimestamp);
});
audioElement.addEventListener('play', function() {
// Check if we need to reconnect after long pause
if (!isReconnecting && pauseTimestamp && (Date.now() - pauseTimestamp) > PAUSE_RECONNECT_THRESHOLD) {
needsReconnect = true;
console.log('Long pause detected, will reconnect when playing starts...');
}
pauseTimestamp = null;
});
// Intercept the playing event to stop stale audio
audioElement.addEventListener('playing', function() {
if (needsReconnect && !isReconnecting) {
isReconnecting = true;
needsReconnect = false;
console.log('Reconnecting stream after long pause to clear stale buffers...');
// Stop the stale audio immediately
audioElement.pause();
// Reset spectrum analyzer before reconnect
if (typeof resetSpectrumAnalyzer === 'function') {
resetSpectrumAnalyzer();
}
audioElement.load(); // Force reconnect to clear accumulated buffer
// Start playing the fresh stream and reinitialize spectrum analyzer
setTimeout(function() {
audioElement.play().catch(err => console.log('Reconnect play failed:', err));
if (typeof initSpectrumAnalyzer === 'function') {
initSpectrumAnalyzer();
console.log('Spectrum analyzer reinitialized after reconnect');
}
isReconnecting = false;
}, 200);
}
});
audioElement.addEventListener('error', function(e) { audioElement.addEventListener('error', function(e) {
console.log('Stream error, attempting reconnect in 3 seconds...'); console.log('Stream error, attempting reconnect in 3 seconds...');
setTimeout(function() { setTimeout(function() {

View File

@ -26,57 +26,6 @@ document.addEventListener('DOMContentLoaded', function() {
if (liveAudio) { if (liveAudio) {
// Reduce buffer to minimize delay // Reduce buffer to minimize delay
liveAudio.preload = 'none'; liveAudio.preload = 'none';
// Track pause timestamp to detect long pauses and reconnect
let pauseTimestamp = null;
let isReconnecting = false;
let needsReconnect = false;
const PAUSE_RECONNECT_THRESHOLD = 10000; // 10 seconds
liveAudio.addEventListener('pause', function() {
pauseTimestamp = Date.now();
console.log('Live stream paused at:', pauseTimestamp);
});
liveAudio.addEventListener('play', function() {
// Check if we need to reconnect after long pause
if (!isReconnecting && pauseTimestamp && (Date.now() - pauseTimestamp) > PAUSE_RECONNECT_THRESHOLD) {
needsReconnect = true;
console.log('Long pause detected, will reconnect when playing starts...');
}
pauseTimestamp = null;
});
// Intercept the playing event to stop stale audio
liveAudio.addEventListener('playing', function() {
if (needsReconnect && !isReconnecting) {
isReconnecting = true;
needsReconnect = false;
console.log('Reconnecting live stream after long pause to clear stale buffers...');
// Stop the stale audio immediately
liveAudio.pause();
// Reset spectrum analyzer before reconnect
if (typeof resetSpectrumAnalyzer === 'function') {
resetSpectrumAnalyzer();
}
liveAudio.load(); // Force reconnect to clear accumulated buffer
// Start playing the fresh stream and reinitialize spectrum analyzer
setTimeout(function() {
liveAudio.play().catch(err => console.log('Reconnect play failed:', err));
if (typeof initSpectrumAnalyzer === 'function') {
initSpectrumAnalyzer();
console.log('Spectrum analyzer reinitialized after reconnect');
}
isReconnecting = false;
}, 200);
}
});
} }
// Restore user quality preference // Restore user quality preference
const selector = document.getElementById('live-stream-quality'); const selector = document.getElementById('live-stream-quality');
@ -649,12 +598,6 @@ function changeLiveStreamQuality() {
// Live stream informatio update // Live stream informatio update
async function updateNowPlaying() { async function updateNowPlaying() {
// Don't update if stream is paused
const liveAudio = document.getElementById('live-stream-audio');
if (liveAudio && liveAudio.paused) {
return;
}
try { try {
const response = await fetch('/api/asteroid/partial/now-playing') const response = await fetch('/api/asteroid/partial/now-playing')
const contentType = response.headers.get("content-type") const contentType = response.headers.get("content-type")

View File

@ -47,64 +47,15 @@
}); });
} }
// Track pause timestamp to detect long pauses and reconnect
let pauseTimestamp = null;
let isReconnecting = false;
let needsReconnect = false;
const PAUSE_RECONNECT_THRESHOLD = 10000; // 10 seconds
audioElement.addEventListener('pause', function() {
pauseTimestamp = Date.now();
console.log('Frame player stream paused at:', pauseTimestamp);
});
audioElement.addEventListener('play', function() {
// Check if we need to reconnect after long pause
if (!isReconnecting && pauseTimestamp && (Date.now() - pauseTimestamp) > PAUSE_RECONNECT_THRESHOLD) {
needsReconnect = true;
console.log('Long pause detected, will reconnect when playing starts...');
}
pauseTimestamp = null;
});
// Intercept the playing event to stop stale audio
audioElement.addEventListener('playing', function() {
if (needsReconnect && !isReconnecting) {
isReconnecting = true;
needsReconnect = false;
console.log('Reconnecting frame player stream after long pause to clear stale buffers...');
// Stop the stale audio immediately
audioElement.pause();
// Reset spectrum analyzer before reconnect
if (typeof resetSpectrumAnalyzer === 'function') {
resetSpectrumAnalyzer();
}
audioElement.load(); // Force reconnect to clear accumulated buffer
// Start playing the fresh stream and reinitialize spectrum analyzer
setTimeout(function() {
audioElement.play().catch(err => console.log('Reconnect play failed:', err));
if (typeof initSpectrumAnalyzer === 'function') {
initSpectrumAnalyzer();
console.log('Spectrum analyzer reinitialized after reconnect');
}
isReconnecting = false;
}, 200);
} else {
console.log('Audio playing');
}
});
// Add event listeners for debugging // Add event listeners for debugging
audioElement.addEventListener('waiting', function() { audioElement.addEventListener('waiting', function() {
console.log('Audio buffering...'); console.log('Audio buffering...');
}); });
audioElement.addEventListener('playing', function() {
console.log('Audio playing');
});
audioElement.addEventListener('error', function(e) { audioElement.addEventListener('error', function(e) {
console.error('Audio error:', e); console.error('Audio error:', e);
}); });
@ -161,12 +112,6 @@
// Update mini now playing display // Update mini now playing display
async function updateMiniNowPlaying() { async function updateMiniNowPlaying() {
// Don't update if stream is paused
const audioElement = document.getElementById('persistent-audio');
if (audioElement && audioElement.paused) {
return;
}
try { try {
const response = await fetch('/api/asteroid/partial/now-playing-inline'); const response = await fetch('/api/asteroid/partial/now-playing-inline');
if (response.ok) { if (response.ok) {

View File

@ -97,12 +97,6 @@
// Update now playing info for popout // Update now playing info for popout
async function updatePopoutNowPlaying() { async function updatePopoutNowPlaying() {
// Don't update if stream is paused
const audioElement = document.getElementById('live-audio');
if (audioElement && audioElement.paused) {
return;
}
try { try {
const response = await fetch('/api/asteroid/partial/now-playing-inline'); const response = await fetch('/api/asteroid/partial/now-playing-inline');
const html = await response.text(); const html = await response.text();
@ -131,60 +125,8 @@
// Initial update // Initial update
updatePopoutNowPlaying(); updatePopoutNowPlaying();
// Auto-reconnect on stream errors and after long pauses // Auto-reconnect on stream errors
const audioElement = document.getElementById('live-audio'); const audioElement = document.getElementById('live-audio');
// Track pause timestamp to detect long pauses and reconnect
let pauseTimestamp = null;
let isReconnecting = false;
let needsReconnect = false;
const PAUSE_RECONNECT_THRESHOLD = 10000; // 10 seconds
audioElement.addEventListener('pause', function() {
pauseTimestamp = Date.now();
console.log('Popout stream paused at:', pauseTimestamp);
});
audioElement.addEventListener('play', function() {
// Check if we need to reconnect after long pause
if (!isReconnecting && pauseTimestamp && (Date.now() - pauseTimestamp) > PAUSE_RECONNECT_THRESHOLD) {
needsReconnect = true;
console.log('Long pause detected, will reconnect when playing starts...');
}
pauseTimestamp = null;
});
// Intercept the playing event to stop stale audio
audioElement.addEventListener('playing', function() {
if (needsReconnect && !isReconnecting) {
isReconnecting = true;
needsReconnect = false;
console.log('Reconnecting popout stream after long pause to clear stale buffers...');
// Stop the stale audio immediately
audioElement.pause();
// Reset spectrum analyzer before reconnect
if (typeof resetSpectrumAnalyzer === 'function') {
resetSpectrumAnalyzer();
}
audioElement.load(); // Force reconnect to clear accumulated buffer
// Start playing the fresh stream and reinitialize spectrum analyzer
setTimeout(function() {
audioElement.play().catch(err => console.log('Reconnect play failed:', err));
if (typeof initSpectrumAnalyzer === 'function') {
initSpectrumAnalyzer();
console.log('Spectrum analyzer reinitialized after reconnect');
}
isReconnecting = false;
}, 200);
}
});
audioElement.addEventListener('error', function(e) { audioElement.addEventListener('error', function(e) {
console.log('Stream error, attempting reconnect in 3 seconds...'); console.log('Stream error, attempting reconnect in 3 seconds...');
setTimeout(function() { setTimeout(function() {