diff --git a/gui.rkt b/gui.rkt index 0dc21f3..ec7f762 100644 --- a/gui.rkt +++ b/gui.rkt @@ -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 "" stored-file (current-milliseconds)))) + (let ((html (format "" + (string-replace (format "~a" stored-file) "\\" "/") + (current-milliseconds)))) (dbg-rktplayer "Html = ~a" html) (send el set-innerHTML! html)))) ) diff --git a/gui/styles.css b/gui/styles.css index 9958cf8..11be3d8 100644 --- a/gui/styles.css +++ b/gui/styles.css @@ -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; } diff --git a/music-library.rkt b/music-library.rkt index ed5b913..a74e9ab 100644 --- a/music-library.rkt +++ b/music-library.rkt @@ -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))) diff --git a/rktplayer.rkt b/rktplayer.rkt index 9fb8afb..44625b5 100644 --- a/rktplayer.rkt +++ b/rktplayer.rkt @@ -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])) )