increase the polling interval for #'update-stream-information
This commit is contained in:
parent
0748466811
commit
afa9f2e172
|
|
@ -112,7 +112,7 @@
|
||||||
(left (/ (- (ps:@ screen width) width) 2))
|
(left (/ (- (ps:@ screen width) width) 2))
|
||||||
(top (/ (- (ps:@ screen height) height) 2))
|
(top (/ (- (ps:@ screen height) height) 2))
|
||||||
(features (+ "width=" width ",height=" height ",left=" left ",top=" top
|
(features (+ "width=" width ",height=" height ",left=" left ",top=" top
|
||||||
",resizable=yes,scrollbars=no,status=no,menubar=no,toolbar=no,location=no")))
|
",resizable=yes,scrollbars=no,status=no,menubar=no,toolbar=no,location=no")))
|
||||||
|
|
||||||
;; Open popout window
|
;; Open popout window
|
||||||
(setf *popout-window*
|
(setf *popout-window*
|
||||||
|
|
@ -314,77 +314,77 @@
|
||||||
;; Error handler
|
;; Error handler
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "error"
|
(add-event-listener "error"
|
||||||
(lambda (err)
|
(lambda (err)
|
||||||
(incf *stream-error-count*)
|
(incf *stream-error-count*)
|
||||||
(ps:chain console (log "Stream error:" err))
|
(ps:chain console (log "Stream error:" err))
|
||||||
|
|
||||||
(if (< *stream-error-count* 3)
|
(if (< *stream-error-count* 3)
|
||||||
;; Auto-retry for first few errors
|
;; Auto-retry for first few errors
|
||||||
(progn
|
(progn
|
||||||
(show-stream-status (+ "⚠️ Stream error. Reconnecting... (attempt " *stream-error-count* ")") "warning")
|
(show-stream-status (+ "⚠️ Stream error. Reconnecting... (attempt " *stream-error-count* ")") "warning")
|
||||||
(setf *reconnect-timeout*
|
(setf *reconnect-timeout*
|
||||||
(set-timeout reconnect-stream 3000)))
|
(set-timeout reconnect-stream 3000)))
|
||||||
;; Too many errors, show manual reconnect
|
;; Too many errors, show manual reconnect
|
||||||
(progn
|
(progn
|
||||||
(show-stream-status "❌ Stream connection lost. Click Reconnect to try again." "error")
|
(show-stream-status "❌ Stream connection lost. Click Reconnect to try again." "error")
|
||||||
(show-reconnect-button))))))
|
(show-reconnect-button))))))
|
||||||
|
|
||||||
;; Stalled handler
|
;; Stalled handler
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "stalled"
|
(add-event-listener "stalled"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(ps:chain console (log "Stream stalled"))
|
(ps:chain console (log "Stream stalled"))
|
||||||
(show-stream-status "⚠️ Stream stalled. Attempting to recover..." "warning")
|
(show-stream-status "⚠️ Stream stalled. Attempting to recover..." "warning")
|
||||||
(setf *reconnect-timeout*
|
(setf *reconnect-timeout*
|
||||||
(set-timeout
|
(set-timeout
|
||||||
(lambda ()
|
(lambda ()
|
||||||
;; Only reconnect if still stalled
|
;; Only reconnect if still stalled
|
||||||
(when (ps:@ audio-element paused)
|
(when (ps:@ audio-element paused)
|
||||||
(reconnect-stream)))
|
(reconnect-stream)))
|
||||||
5000)))))
|
5000)))))
|
||||||
|
|
||||||
;; Waiting handler (buffering)
|
;; Waiting handler (buffering)
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "waiting"
|
(add-event-listener "waiting"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(ps:chain console (log "Stream buffering..."))
|
(ps:chain console (log "Stream buffering..."))
|
||||||
(show-stream-status "⏳ Buffering..." "info"))))
|
(show-stream-status "⏳ Buffering..." "info"))))
|
||||||
|
|
||||||
;; Playing handler - clear any error states
|
;; Playing handler - clear any error states
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "playing"
|
(add-event-listener "playing"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(setf *stream-error-count* 0)
|
(setf *stream-error-count* 0)
|
||||||
(hide-stream-status)
|
(hide-stream-status)
|
||||||
(hide-reconnect-button)
|
(hide-reconnect-button)
|
||||||
(when *reconnect-timeout*
|
(when *reconnect-timeout*
|
||||||
(clear-timeout *reconnect-timeout*)
|
(clear-timeout *reconnect-timeout*)
|
||||||
(setf *reconnect-timeout* nil)))))
|
(setf *reconnect-timeout* nil)))))
|
||||||
|
|
||||||
;; Pause handler - track when paused for long pause detection
|
;; Pause handler - track when paused for long pause detection
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "pause"
|
(add-event-listener "pause"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(setf *last-play-attempt* (ps:chain |Date| (now))))))
|
(setf *last-play-attempt* (ps:chain |Date| (now))))))
|
||||||
|
|
||||||
;; Play handler - detect long pauses that need reconnection
|
;; Play handler - detect long pauses that need reconnection
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "play"
|
(add-event-listener "play"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ((pause-duration (- (ps:chain |Date| (now)) *last-play-attempt*)))
|
(let ((pause-duration (- (ps:chain |Date| (now)) *last-play-attempt*)))
|
||||||
;; If paused for more than 30 seconds, reconnect to get fresh stream
|
;; If paused for more than 30 seconds, reconnect to get fresh stream
|
||||||
(when (> pause-duration 30000)
|
(when (> pause-duration 30000)
|
||||||
(ps:chain console (log "Long pause detected, reconnecting for fresh stream..."))
|
(ps:chain console (log "Long pause detected, reconnecting for fresh stream..."))
|
||||||
(reconnect-stream))))))
|
(reconnect-stream))))))
|
||||||
|
|
||||||
;; Spectrum analyzer hooks
|
;; Spectrum analyzer hooks
|
||||||
(when (ps:@ window |initSpectrumAnalyzer|)
|
(when (ps:@ window |initSpectrumAnalyzer|)
|
||||||
(ps:chain audio-element (add-event-listener "play"
|
(ps:chain audio-element (add-event-listener "play"
|
||||||
(lambda () (ps:chain window (init-spectrum-analyzer))))))
|
(lambda () (ps:chain window (init-spectrum-analyzer))))))
|
||||||
|
|
||||||
(when (ps:@ window |stopSpectrumAnalyzer|)
|
(when (ps:@ window |stopSpectrumAnalyzer|)
|
||||||
(ps:chain audio-element (add-event-listener "pause"
|
(ps:chain audio-element (add-event-listener "pause"
|
||||||
(lambda () (ps:chain window (stop-spectrum-analyzer)))))))
|
(lambda () (ps:chain window (stop-spectrum-analyzer)))))))
|
||||||
|
|
||||||
(defun redirect-when-frame ()
|
(defun redirect-when-frame ()
|
||||||
(let* ((path (ps:@ window location pathname))
|
(let* ((path (ps:@ window location pathname))
|
||||||
|
|
@ -399,49 +399,49 @@
|
||||||
|
|
||||||
;; Initialize on page load
|
;; Initialize on page load
|
||||||
(ps:chain document
|
(ps:chain document
|
||||||
(add-event-listener
|
(add-event-listener
|
||||||
"DOMContentLoaded"
|
"DOMContentLoaded"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
;; Update stream information
|
;; Update stream information
|
||||||
(update-stream-information)
|
(update-stream-information)
|
||||||
|
|
||||||
;; Periodically update stream info if in frameset
|
;; Periodically update stream info if in frameset
|
||||||
(let ((is-frameset-page (not (= (ps:@ window parent) (ps:@ window self)))))
|
(let ((is-frameset-page (not (= (ps:@ window parent) (ps:@ window self)))))
|
||||||
(when is-frameset-page
|
(when is-frameset-page
|
||||||
(set-interval update-stream-information 1000)))
|
(set-interval update-stream-information 10000)))
|
||||||
|
|
||||||
;; Update now playing
|
;; Update now playing
|
||||||
(update-now-playing)
|
(update-now-playing)
|
||||||
|
|
||||||
;; Attach event listeners to audio element
|
;; Attach event listeners to audio element
|
||||||
(let ((audio-element (ps:chain document (get-element-by-id "live-audio"))))
|
(let ((audio-element (ps:chain document (get-element-by-id "live-audio"))))
|
||||||
(when audio-element
|
(when audio-element
|
||||||
(attach-audio-event-listeners audio-element)))
|
(attach-audio-event-listeners audio-element)))
|
||||||
|
|
||||||
;; Check frameset preference
|
;; Check frameset preference
|
||||||
(let ((path (ps:@ window location pathname))
|
(let ((path (ps:@ window location pathname))
|
||||||
(is-frameset-page (not (= (ps:@ window parent) (ps:@ window self)))))
|
(is-frameset-page (not (= (ps:@ window parent) (ps:@ window self)))))
|
||||||
(when (and (= (ps:chain local-storage (get-item "useFrameset")) "true")
|
(when (and (= (ps:chain local-storage (get-item "useFrameset")) "true")
|
||||||
(not is-frameset-page)
|
(not is-frameset-page)
|
||||||
(ps:chain path (includes "/asteroid")))
|
(ps:chain path (includes "/asteroid")))
|
||||||
(setf (ps:@ window location href) "/asteroid/frameset"))
|
(setf (ps:@ window location href) "/asteroid/frameset"))
|
||||||
|
|
||||||
(redirect-when-frame)))))
|
(redirect-when-frame)))))
|
||||||
|
|
||||||
;; Update now playing every 5 seconds
|
;; Update now playing every 5 seconds
|
||||||
(set-interval update-now-playing 5000)
|
(set-interval update-now-playing 5000)
|
||||||
|
|
||||||
;; Listen for messages from popout window
|
;; Listen for messages from popout window
|
||||||
(ps:chain window
|
(ps:chain window
|
||||||
(add-event-listener
|
(add-event-listener
|
||||||
"message"
|
"message"
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(cond
|
(cond
|
||||||
((= (ps:@ event data type) "popout-opened")
|
((= (ps:@ event data type) "popout-opened")
|
||||||
(update-popout-button t))
|
(update-popout-button t))
|
||||||
((= (ps:@ event data type) "popout-closed")
|
((= (ps:@ event data type) "popout-closed")
|
||||||
(update-popout-button nil)
|
(update-popout-button nil)
|
||||||
(setf *popout-window* nil))))))
|
(setf *popout-window* nil))))))
|
||||||
|
|
||||||
;; Check if popout is still open periodically
|
;; Check if popout is still open periodically
|
||||||
(set-interval
|
(set-interval
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue