Adding settings.

This commit is contained in:
2026-07-08 00:09:45 +02:00
parent 5e332522e3
commit f949e2dbb3
10 changed files with 438 additions and 75 deletions
+55 -20
View File
@@ -20,6 +20,10 @@
[buffer-min-seconds 4]
)
(define player-kind 'local)
(define player-host #f)
(define player-basepaths #f)
(define player #f)
(define playlist #f)
(define state 'stopped)
@@ -43,40 +47,71 @@
(define (clear-music-ids!)
(lru-clear track-cache))
;;(define x 0)
(define (audio-state-cb handle player-state st*)
(set! full-state st*)
(let ((st (audio-state player)))
(when (or (eq? st 'paused) (eq? st 'playing))
(time-updater (audio-at-second player)
(audio-duration player))
(when (not (= music-id (audio-music-id player)))
(set! music-id (audio-music-id player))
(let ((track-nr (music-id->track-nr music-id)))
(if (eq? track-nr #f)
(error "Unexpected: no track-nr for given music-id")
(track-nr-updater track-nr))))
;;(when (< x 5)
;; (displayln st*)
;; (set! x (+ x 1)))
(unless (or (not (eq? player handle)) (eq? player #f))
(let ((st (audio-state player)))
(when (or (eq? st 'paused) (eq? st 'playing))
(time-updater (audio-at-second player)
(audio-duration player))
(when (not (= music-id (audio-music-id player)))
(set! music-id (audio-music-id player))
(let ((track-nr (music-id->track-nr music-id)))
(if (eq? track-nr #f)
(warn-rktplayer "Unexpected: no track-nr for given music-id")
(track-nr-updater track-nr))))
)
(state-updater st)
(repeat-updater repeat)
(if (or (eq? player-state 'quit) (eq? player-state 'stopped))
(audio-info-cb 0 0 0 'none)
(audio-info-cb (audio-rate player) (audio-channels player)
(audio-bits player) (audio-decoder player)))
)
(state-updater st)
(repeat-updater repeat)
(if (or (eq? player-state 'quit) (eq? player-state 'stopped))
(audio-info-cb 0 0 0 'none)
(audio-info-cb (audio-rate player) (audio-channels player)
(audio-bits player) (audio-decoder player)))
)
)
(define (on-eof-stream-cb handle)
(let ((track-nr (music-id->track-nr music-id)))
(send this next)))
(when (and (eq? player handle) (not (eq? player #f)))
(let ((track-nr (music-id->track-nr music-id)))
(send this next))))
;(define ap (make-audio-player audio-player-state audio-player-eof
; #:remote-host "hans@mahler.thuis.local"
; #:replace-base-paths '(("\\\\panderleou\\music" . "/muziek"))))
(define (check-player)
;(displayln "check-player called")
(when (eq? player #f)
(set! player (make-audio-player audio-state-cb on-eof-stream-cb))
(set! player
(if (eq? player-kind 'local)
(make-audio-player audio-state-cb on-eof-stream-cb)
(make-audio-player audio-state-cb on-eof-stream-cb
#:remote-host player-host
#:replace-base-paths player-basepaths)))
(audio-ao-buf-ms! player 500)
(audio-buf-seconds! player buffer-min-seconds buffer-max-seconds)
))
(define/public (change-player kind #:host [host #f] #:basepaths [basepaths #f])
(let ((op player))
(unless (eq? player #f)
(set! player #f)
(audio-quit! op)
;(displayln "Player quit")
)
;(displayln "HE!")
(set! player-kind kind)
(set! player-host host)
(set! player-basepaths basepaths)
;(displayln (format "kind: ~a, host: ~a, bp: ~a, player: ~a" player-kind player-host player-basepaths player))
))
(define/public (get-volume)
(check-player)
(audio-volume player))