Complete refactoring for rktplayer, in order to make it play on DLNA renderers and also use UpNP media server resources.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#lang racket/base
|
||||
|
||||
(require racket/class)
|
||||
|
||||
(provide media-item%)
|
||||
|
||||
;; Common base class for entries returned by a media container.
|
||||
(define media-item%
|
||||
(class object%
|
||||
(init-field
|
||||
kind
|
||||
[id #f])
|
||||
|
||||
(unless (memq kind '(container track))
|
||||
(raise-arguments-error
|
||||
'media-item%
|
||||
"invalid media item kind"
|
||||
"expected" '(container track)
|
||||
"kind" kind))
|
||||
|
||||
(define/public (get-id)
|
||||
id)
|
||||
|
||||
(define/public (get-kind)
|
||||
kind)
|
||||
|
||||
(define/public (get-container)
|
||||
(and (eq? kind 'container)
|
||||
this))
|
||||
|
||||
(define/public (get-track)
|
||||
(and (eq? kind 'track)
|
||||
this))
|
||||
|
||||
(super-new)))
|
||||
|
||||
(module+ test
|
||||
(require rackunit)
|
||||
|
||||
(define container
|
||||
(new media-item%
|
||||
[id 'container-id]
|
||||
[kind 'container]))
|
||||
|
||||
(define track
|
||||
(new media-item%
|
||||
[id 'track-id]
|
||||
[kind 'track]))
|
||||
|
||||
(check-eq? (send container get-container) container)
|
||||
(check-false (send container get-track))
|
||||
(check-eq? (send track get-track) track)
|
||||
(check-false (send track get-container))
|
||||
(check-equal? (send container get-id) 'container-id)
|
||||
(check-equal? (send track get-kind) 'track)
|
||||
(check-exn
|
||||
exn:fail:contract?
|
||||
(lambda ()
|
||||
(new media-item% [kind 'unknown]))))
|
||||
Reference in New Issue
Block a user