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

@@ -239,18 +239,21 @@
(displayln (format "Open booklet ~a" path)))
(define/public (open-folder path)
(displayln (format "open folder ~a" path)))
(displayln path)
(let ((folder (if (file-exists? path) (path-only path) path)))
(open-file-manager folder)))
;(shell-execute #f folder #f #f 'sw_show)))
(define/public (play)
(displayln "Play button clicked")
)
(define/public (next-track)
(displayln "Next track")
(send player next)
)
(define/public (previous-track)
(displayln "Previous track")
(send player previous)
)
(define/public (repeat)

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))

View File

@@ -41,16 +41,40 @@
(super-new)
(begin
(unless (eq? file #f)
(let ((tags (id3-tags (format "~a" file))))
(set! title (tags-title tags))
(set! artist (tags-artist tags))
(set! album (tags-album tags))
(set! number (tags-track tags))
(set! length (tags-length tags))
(let ((f (if (path? file) (path->string file) file)))
(let ((tags (id3-tags f))
(tmpfile #f))
(unless (tags-valid? tags)
(the-displayln "Invalid, try to open a copy of this file")
(let ((nfile (make-temporary-file "rktplayer-~a" #:copy-from f)))
(set! tags (id3-tags nfile))
(set! tmpfile nfile)
)
)
(if (tags-valid? tags)
(begin
(set! title (tags-title tags))
(set! artist (tags-artist tags))
(set! album (tags-album tags))
(set! number (tags-track tags))
(set! length (tags-length tags))
)
(begin
(set! title "invalid tags")
(set! artist "invalid tags")
(set! album "invalid tags")
(set! number number)
(set! length -1)
)
)
(unless (eq? tmpfile #f)
(delete-file tmpfile))
)
)
)
)
))
)
)
(define list-len length)
@@ -85,6 +109,7 @@
(if (directory-exists? p)
(read-tracks-internal p)
(when (and (file-exists? p) (can-add? p))
;(displayln (format "Adding ~a" p))
(add-track* p)))))
content))
'no-file-or-dir

View File

@@ -10,6 +10,7 @@
mktable
simple-row-formatter
while
open-file-manager
)
@@ -70,5 +71,11 @@
)
)
(define (open-file-manager path)
(let ((folder (if (path? path) (path->string path) path)))
(case (system-type 'os)
[(windows) (process (string-append "explorer.exe " folder))]
[(macosx) (process (string-append "open " folder))]
[else (process (string-append "xdg-open " folder))]))
)