diff --git a/gui.rkt b/gui.rkt
index f820642..a0ff7df 100644
--- a/gui.rkt
+++ b/gui.rkt
@@ -147,11 +147,21 @@
(unless (eq? stored-file #f)
(dbg-rktplayer "Setting album art")
(let ((el (send this element 'album-art)))
- (let ((html (format "
"
+ (let ((html (format "
"
(format "~a" stored-file)
(current-milliseconds))))
(dbg-rktplayer "Html = ~a" html)
(send el set-innerHTML! html)
+ (when (send track has-booklet?)
+ (let ((booklet-file (send track booklet-file)))
+ (send this bind! 'album-image 'contextmenu
+ (λ (el evt data)
+ (let ((mnu (wv-menu 'image-menu
+ (wv-menu-item 'm-booklet (tr "Open booklet")
+ #:callback (λ () (send this open-booklet booklet-file #t)))))
+ (clientX (hash-ref data 'clientX 60))
+ (clientY (hash-ref data 'clientY 60)))
+ (send this popup-menu! mnu clientX clientY))))))
)))
)
)
@@ -173,26 +183,26 @@
)
(define (update-state st)
- (dbg-rktplayer "state: ~a" st)
(unless (eq? st state)
(dbg-rktplayer "Changing to state ~a" st)
(let ((el (send this element 'paused)))
- (unless (eq? state #f) ; Prevent setting src twice very fast
- (cond ((or (eq? st 'playing) (eq? st 'play))
- (set-play-button "buttons/pause.svg")
- (send el set-innerHTML! '(span (tr "playing"))))
+ (cond ((or (eq? st 'playing) (eq? st 'play))
+ (set-play-button "buttons/pause.svg")
+ (send el set-innerHTML! '(span (tr "playing"))))
((eq? st 'stopped)
(set-play-button "buttons/play.svg")
(send el set-innerHTML! '(span (tr "stopped"))))
((eq? st 'paused)
(set-play-button "buttons/play.svg")
(send el set-innerHTML! '(span ((class "blink")) (tr "paused"))))
+ ((eq? st 'quit)
+ (void))
(else
(warn-rktplayer "Unkown state for update-state ~a" st)
(send el set-innerHTML! (list 'span
- '((class "blink"))
- (format "~a: ~a" (tr "Unknown state") st))))
- )))
+ '((class "blink"))
+ (format "~a: ~a" (tr "Unknown state") st))))
+ ))
(set! state st)
)
)
@@ -309,10 +319,13 @@
(send this update-tabs))
(define (update-audio-info rate channels bits audio-format)
- (send el-bits set-innerHTML! (format "~a ~a" bits (tr "bits")))
- (send el-channels set-innerHTML! (format "~a ~a" channels (tr "channels")))
- (send el-rate set-innerHTML! (format "~a Hz" rate))
- (send el-format set-innerHTML! (format "~a" audio-format))
+ (let ((format-num (λ (x) (if (= x 0) "-" x)))
+ (format-dec (λ (x) (if (eq? x 'none) "-" x))))
+ (send el-bits set-innerHTML! (format "~a ~a" (format-num bits) (tr "bits")))
+ (send el-channels set-innerHTML! (format "~a ~a" (format-num channels) (tr "channels")))
+ (send el-rate set-innerHTML! (format "~a Hz" (format-num rate)))
+ (send el-format set-innerHTML! (format "~a" (format-dec audio-format)))
+ )
)
(define (update-repeat state)
@@ -396,6 +409,10 @@
(send this update-tabs)
(send this update-library)
(send this update-playlist)
+
+ (when (eq? state #f)
+ (update-audio-info 0 0 0 'none)
+ (update-state 'stopped))
)
(define el-dragged #f)
@@ -564,9 +581,10 @@
(send this update-playlist)
)
- (define/public (open-booklet path)
- (let ((booklet (build-path path "booklet.pdf")))
- (dbg-rktplayer "Open booklet ~a" path)
+ (define/public (open-booklet path . is-file*)
+ (let* ((is-file (if (null? is-file*) #f (eq? (car is-file*) #t)))
+ (booklet (if is-file path (build-path path "booklet.pdf"))))
+ (dbg-rktplayer "Open booklet ~a" booklet)
(open-app booklet)))
(define/public (open-folder path)
@@ -698,6 +716,7 @@
(set! playlist (new playlist% [settings (send settings clone 'playlists)]))
(send player set-list! playlist)
(dbg-rktplayer "playlist = ~a" playlist)
+
(semaphore-post initialized)
)
)
diff --git a/player.rkt b/player.rkt
index b700a3f..3984a68 100644
--- a/player.rkt
+++ b/player.rkt
@@ -44,7 +44,7 @@
(lru-clear track-cache))
- (define (audio-state-cb handle st*)
+ (define (audio-state-cb handle player-state st*)
(set! full-state st*)
(let ((st (audio-state player)))
(when (or (eq? st 'paused) (eq? st 'playing))
@@ -59,8 +59,10 @@
)
(state-updater st)
(repeat-updater repeat)
- (audio-info-cb (audio-rate player) (audio-channels player)
- (audio-bits player) (audio-decoder player))
+ (if (or (eq? player-state 'quit) (eq? player-state 'stopped))
+ (audio-info-cb 0 0 0 'none)
+ (audio-info-cb (audio-rate player) (audio-channels player)
+ (audio-bits player) (audio-decoder player)))
)
)
@@ -70,7 +72,10 @@
(define (check-player)
(when (eq? player #f)
- (set! player (make-audio-player audio-state-cb on-eof-stream-cb))))
+ (set! player (make-audio-player audio-state-cb on-eof-stream-cb))
+ (audio-ao-buf-ms! player 500)
+ (audio-buf-seconds! player buffer-min-seconds buffer-max-seconds)
+ ))
(define/public (get-volume)
(check-player)
diff --git a/playlist.rkt b/playlist.rkt
index 68b0457..b45bb5d 100644
--- a/playlist.rkt
+++ b/playlist.rkt
@@ -51,6 +51,14 @@
(define/public (get-length) length)
(define/public (get-id) my-id)
+ (define/public (booklet-file)
+ (let* ((dir (path-only file))
+ (booklet-file (build-path dir "booklet.pdf")))
+ booklet-file))
+
+ (define/public (has-booklet?)
+ (file-exists? (send this booklet-file)))
+
(define/public (track< t2)
(if (string-ci album (send t2 get-album))
#t
diff --git a/rktplayer.rkt b/rktplayer.rkt
index 3d5bfe5..45cc192 100644
--- a/rktplayer.rkt
+++ b/rktplayer.rkt
@@ -44,6 +44,11 @@
(send rktplayer-window close)
(exit)
)
+
+(define-syntax ignore
+ (syntax-rules ()
+ ((_ body)
+ #t)))
(define (run . no-exit)
@@ -59,6 +64,7 @@
)
(set! rktplayer-window window)
(set! rktplayer-tray tray)
+ (ignore
(thread (λ ()
(sleep 5)
(let ((prg (string-append "let f_evt_info = window.rkt_event_info;\n"
@@ -91,6 +97,7 @@
(return 42)))))|#
(displayln prg)
(displayln (send window call-js prg)))))
+ )
(when (or (null? no-exit)
(not (eq? (car no-exit) #t)))
(webview-wait-for-quit)