#lang racket/base (require "audio-player.rkt" simple-log "private/utils.rkt" racket-sprintf racket/runtime-path racket/path early-return "tests.rkt" ) (define place-mode #f) (define run-queue #f) (define (set-test a) (set! run-queue a)) (define play-queue (list test-file2 test-file3 test-file4)) (define current-sec -1) (define (to-time-str s*) (let* ((s (round s*)) (minutes (quotient s 60)) (seconds (remainder s 60)) ) (sprintf "%02d:%02d" minutes seconds))) (define (audio-player-state h st) (early-return ((? (not (audio-play? h)) => 'done)) (let* ((f (audio-file h)) (name (if (eq? f #f) "none" (file-name-from-path f))) (sec* (audio-at-second h)) (sec (if (eq? sec* #f) 0 (round sec*))) (msg (hash-ref st 'msg "none")) (bs (hash-ref st 'buf-size 0)) (dur* (audio-duration h)) (dur (if (eq? dur* #f) 0 (round dur*))) ) (unless (= current-sec sec) (displayln (format "~a (~a): ~a - ~a - ~a - ~a - ~a - ~a" name (audio-music-id h) (to-time-str sec) (to-time-str dur) (audio-state h) (audio-volume h) bs msg)) (set! current-sec sec) ) ) ) ) (define (audio-player-eof h) (dbg-sound "audio-player-eof called") (when (eq? run-queue 'queue) (if (null? play-queue) (audio-quit! h) (begin (audio-play! h (car play-queue)) (set! play-queue (cdr play-queue)) ) )) (when (eq? run-queue 'once) (set! run-queue #f) (audio-play! h test-file3)) ) (define h (make-audio-player audio-player-state audio-player-eof #:use-place place-mode)) (sl-log-to-display) (audio-player-eof h)