This commit is contained in:
2026-02-24 23:28:18 +01:00
parent 8fb7cca9c2
commit 177829ccb6
4 changed files with 90 additions and 23 deletions

View File

@@ -35,6 +35,8 @@
(define current-length 0)
(define current-seconds 0)
(define repeat 'no-repeat) ;; no-repeat, repeat-1, repeat-all
(define play-time-updater-state 'stopped)
(define (check-ao-handle)
@@ -57,7 +59,7 @@
(displayln "Starting play-time-updater")
(thread (λ ()
(define (updater)
(if (eq? ao-handle #f)
(if (or (eq? ao-handle #f) closing)
(begin
(set! play-time-updater-state 'stopped)
(displayln "Stopping play-time-updater")
@@ -121,10 +123,11 @@
(displayln (format "opening flac handle for file: ~a" file))
(set! flac-handle (flac-open file flac-meta flac-play))
(displayln "Starting flac-read")
(flac-read flac-handle)
(set! state 'track-feeded)
(displayln "Flac read stopped")
'track-feeded
(let ((result (flac-read flac-handle)))
(if (eq? result 'end-of-stream)
(set! state 'track-feeded)
(displayln "Flac read stopped")))
'worker-done
)
)
)
@@ -190,17 +193,46 @@
)
(define/public (play-track i)
(unless (eq? flac-handle #f)
(flac-stop flac-handle)
(set! flac-handle #f)
)
(displayln (format "play-track ~a" i))
;(unless (eq? flac-handle #f)
; (flac-stop flac-handle)
; (set! flac-handle #f)
; )
;(set! track i)
;(set! ct-data (send pl track i))
;(while (eq? state 'playing)
; (sleep 0.1))
;(unless (eq? ao-handle #f)
; (ao-clear-async ao-handle))
;(set! state 'play)
;(track-nr-updater i)
(set! state 'stopped)
(close-player*)
(set! track i)
(set! ct-data (send pl track i))
(while (eq? state 'playing)
(sleep 0.1))
(set! state 'play)
(track-nr-updater i)
(track-nr-updater track)
)
(define/public (next)
(if (= (send pl length) 0)
#f
(let ((idx track))
(set! idx (+ idx 1))
(when (>= idx (send pl length))
(set! idx 0))
(send this play-track idx))
))
(define/public (previous)
(if (= (send pl length) 0)
#f
(let ((idx track))
(set! idx (- idx 1))
(when (< idx 0)
(set! idx (- (send pl length) 1)))
(send this play-track idx)
)))
(define (state-machine)
(let ((st (orig-current-seconds))