New file getter implemented. Windows is stubborn.
This commit is contained in:
12
gui.rkt
12
gui.rkt
@@ -46,7 +46,13 @@
|
|||||||
(define el-at #f)
|
(define el-at #f)
|
||||||
(define el-length #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 current-music-path #f)
|
||||||
(define playlist #f)
|
(define playlist #f)
|
||||||
|
|
||||||
@@ -116,7 +122,9 @@
|
|||||||
(unless (eq? stored-file #f)
|
(unless (eq? stored-file #f)
|
||||||
(dbg-rktplayer "Setting album art")
|
(dbg-rktplayer "Setting album art")
|
||||||
(let ((el (send this element '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)
|
(dbg-rktplayer "Html = ~a" html)
|
||||||
(send el set-innerHTML! html))))
|
(send el set-innerHTML! html))))
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ table.music-library tr td {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.music-library tr:hover td {
|
table.music-library tr td:hover {
|
||||||
background: #e0e0e0;
|
background: #e0e0e0;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,9 @@
|
|||||||
(define (library-formatter row)
|
(define (library-formatter row)
|
||||||
(let* ((file-entry (car row))
|
(let* ((file-entry (car row))
|
||||||
(file-id (format "file-~a" (cadr 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)
|
;(displayln row)
|
||||||
(list (list 'td (list (list 'class "library-entry") (list 'id file-id) (list 'file (format "~a" the-file)))
|
(list (list 'td (list (list 'class "library-entry") (list 'id file-id) (list 'file (format "~a" the-file)))
|
||||||
|
|||||||
@@ -7,37 +7,40 @@
|
|||||||
racket-webview
|
racket-webview
|
||||||
racket/runtime-path
|
racket/runtime-path
|
||||||
"utils.rkt"
|
"utils.rkt"
|
||||||
|
net/uri-codec
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-runtime-path rkt-gui-dir "gui")
|
(define-runtime-path rkt-gui-dir "gui")
|
||||||
;(ao-set-async-mode! 'ffi)
|
|
||||||
|
|
||||||
(define log-file (build-path (find-system-path 'home-dir) ".rktplayer.log"))
|
(define log-file (build-path (find-system-path 'home-dir) ".rktplayer.log"))
|
||||||
(sl-log-to-file log-file)
|
(sl-log-to-file log-file)
|
||||||
|
|
||||||
(displayln (format "Logging to file ~a" 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)
|
(define (run)
|
||||||
(let* ((ini (new ini% [file 'rktplayer]))
|
(let* ((ini (new ini% [file 'rktplayer]))
|
||||||
(context (new wv-context%
|
(context (new wv-context%
|
||||||
[base-path rkt-gui-dir]
|
[base-path rkt-gui-dir]
|
||||||
[ini ini]
|
[ini ini]
|
||||||
[file-getter (webview-standard-file-getter
|
[file-getter my-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)))
|
|
||||||
)]
|
|
||||||
))
|
))
|
||||||
(window (new rktplayer% [wv-context context]))
|
(window (new rktplayer% [wv-context context]))
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user