Browse Source

fixed bugs

master
wes 12 years ago
parent
commit
a69e2e847f
  1. 2
      config_parser.rkt
  2. 11
      lazyplay.rkt
  3. 4
      lazyplay.sexp

2
config_parser.rkt

@ -2,7 +2,7 @@
#lang racket #lang racket
(require "helpers.rkt") (require "helpers.rkt")
(define ip (open-input-file "lazyplay.sexp")) (define ip (open-input-file "/home/wes/lisp/lazyplay/lazyplay.sexp"))
(define parsed (define parsed
(read ip)) (read ip))
(close-input-port ip) (close-input-port ip)

11
lazyplay.rkt

@ -6,13 +6,11 @@
(require "config_parser.rkt") (require "config_parser.rkt")
(define args (vector->list (current-command-line-arguments))) (define args (vector->list (current-command-line-arguments)))
; args: filename, mplayer-args
; optional: directory
(hash-ref settings "args" "")
(define file-types (make-hash)) (define file-types (make-hash))
(define media-player (string->path (hash-ref settings "player" "/usr/bin/mplayer"))) (define media-player (string->path (hash-ref settings "player" "/usr/bin/mplayer")))
(define player-args (hash-ref settings "args" "")) (define player-args (hash-ref settings "args" ""))
(update file-types (hash-ref settings "file-types" '(("avi" #t)))) (update file-types (hash-ref settings "filetypes" '(("avi" #t))))
(define (file-list) ; list of files in the current working directory (define (file-list) ; list of files in the current working directory
(map path->string ; get the strings from the list of paths (map path->string ; get the strings from the list of paths
@ -86,19 +84,20 @@
(cond (cond
((compose not thread-running?) player-thread ; if the thread is not running then return ((compose not thread-running?) player-thread ; if the thread is not running then return
'())) '()))
(display "> ")
(let* ((input (read-line (current-input-port) 'linefeed))) (let* ((input (read-line (current-input-port) 'linefeed)))
input input
(cond ((eof-object? input) '()) (cond ((eof-object? input) '())
(else (else
(thread-send player-thread input) (thread-send player-thread input)
(controller player-thread))))) (controller player-thread)))))
(play-list)
(define player-thread (thread (lambda () (play (play-list) played player-args)))) (define player-thread (thread (lambda () (play (play-list) played player-args))))
(define controller-thread (thread (lambda () (controller player-thread)))) (define controller-thread (thread (lambda () (controller player-thread))))
; check to see if the player is running, and if not then kill the controller ; check to see if the player is running, and if not then kill the controller
(define (check) (define (check)
(sleep 20) ; (sleep 20)
(cond (((compose not thread-running?) player-thread) (kill-thread controller-thread)) (cond (((compose not thread-running?) player-thread) (kill-thread controller-thread))
(else (check)))) (else (check))))

4
lazyplay.sexp

@ -1,3 +1,3 @@
(("player" "/usr/bin/mplayer") (("player" "/usr/bin/mplayer")
("filetypes" (("avi" #t) ("mp4" #t))) ("filetypes" (("avi" #t) ("mp4" #t) ("mkv" #t)))
("args" "-ss 5000")) ("args" ""))