New file getter implemented. Windows is stubborn.

This commit is contained in:
2026-04-11 23:11:24 +02:00
parent fb99e97577
commit 2f0b91a6c6
4 changed files with 34 additions and 21 deletions

12
gui.rkt
View File

@@ -46,7 +46,13 @@
(define el-at #f)
(define el-length #f)
(define music-library (send settings get 'music-library (find-system-path 'home-dir)))
(define music-library
(let ((path (format "~a" (send settings get 'music-library (find-system-path 'home-dir)))))
(when (eq? (system-type 'os) 'windows)
(set! path (string-replace path "/" "\\")))
(dbg-rktplayer "music-library: ~a" path)
path))
(define current-music-path #f)
(define playlist #f)
@@ -116,7 +122,9 @@
(unless (eq? stored-file #f)
(dbg-rktplayer "Setting album art")
(let ((el (send this element 'album-art)))
(let ((html (format "<img src=\"~a?~a\" />" stored-file (current-milliseconds))))
(let ((html (format "<img src=\"/get-image?~a&~a\" />"
(string-replace (format "~a" stored-file) "\\" "/")
(current-milliseconds))))
(dbg-rktplayer "Html = ~a" html)
(send el set-innerHTML! html))))
)

View File

@@ -124,7 +124,7 @@ table.music-library tr td {
user-select: none;
}
table.music-library tr:hover td {
table.music-library tr td:hover {
background: #e0e0e0;
color: black;
}

View File

@@ -35,7 +35,9 @@
(define (library-formatter row)
(let* ((file-entry (car row))
(file-id (format "file-~a" (cadr row)))
(the-file (if (equal? file-id "lib-up") ".." file-entry))
(the-file (string-replace
(if (equal? file-id "lib-up") ".." (format "~a" file-entry))
"\\" "/"))
)
;(displayln row)
(list (list 'td (list (list 'class "library-entry") (list 'id file-id) (list 'file (format "~a" the-file)))

View File

@@ -7,37 +7,40 @@
racket-webview
racket/runtime-path
"utils.rkt"
net/uri-codec
)
(define-runtime-path rkt-gui-dir "gui")
;(ao-set-async-mode! 'ffi)
(define log-file (build-path (find-system-path 'home-dir) ".rktplayer.log"))
(sl-log-to-file log-file)
(displayln (format "Logging to file ~a" log-file))
(define (my-file-getter url)
(dbg-rktplayer "my-file-getter - url = ~a" url)
(when (string-prefix? url "/")
(set! url (substring url 1)))
(if (string-prefix? url "get-image")
(let* ((str (uri-decode url))
(idx (string-find str "?")))
(set! str (substring str (+ idx 1)))
(set! idx (string-find str "&"))
(set! str (substring str 0 idx))
(dbg-rktplayer "returning file ~a" str)
(build-path str)
)
(build-path rkt-gui-dir url)
)
)
(define (run)
(let* ((ini (new ini% [file 'rktplayer]))
(context (new wv-context%
[base-path rkt-gui-dir]
[ini ini]
[file-getter (webview-standard-file-getter
rkt-gui-dir
#:not-exist
(λ (file base-path path)
(dbg-rktplayer "FILE:~a, ~a, ~a" file base-path path)
(let ((prefix (path->string
(build-path (find-system-path 'cache-dir)
"rktplayer-cover-image"))))
(dbg-rktplayer "prefix= ~a" prefix)
(dbg-rktplayer "is-prefix? = ~a" (string-prefix? file prefix))
(if (string-prefix? file prefix)
(begin
(dbg-rktplayer "RETURNING FILE")
file)
path)))
)]
[file-getter my-file-getter]
))
(window (new rktplayer% [wv-context context]))
)