;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MOVIE PLAYS BACK AND FORTH
;;
;; Download a medium sized quicktime trailer from apple
;; Load it into quicktime-pro and export it in a non-IFrame
;; format (gfx:get-movie-frame does not support iframes).
;; I would suggest using jpeg photo.
;;
;; This example plays a movie forwards and backwards
;; at the same time. frames from the head and tail of the
;; movie are composited on each other using gfx:image2image
;; with a 50% transperency and then displayed.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define canvas (gfx:make-canvas 640 480))
(define movie (gfx:load-movie "/tmp/myfilm.mov"))
(define mlgth (- (gfx:get-movie-duration movie) 1.0))
(define frame-length (* *second* 0.1))
;; Note: often an image from get-movie-frame will be 24bit (i.e. no alpha channel)
;; if you want to use text2image image2image or path2image you will need a 32bit
;; image (i.e. one with an alpha channel)
;;
;; Therefore in this example we create a blank image (which will always be 32bit)
;; and draw image into the new blank image
(define loop
(lambda (time mtime)
(let ((pic1 (gfx:get-movie-frame movie mtime))
(pic2 (gfx:get-movie-frame movie (- mlgth mtime)))
(new (gfx:make-image 640 480)))
; composit pic2 on pict1 with a 50% transparency
(gfx:image2image pic1 new 1 '(0 0 600 600))
(gfx:image2image pic2 new .5 '(0 0 600 600))
(gfx:draw-image time canvas new 1.0)
(set! time (+ time frame-length))
(if (< mtime mlgth)
(callback (- time 1000) 'loop time (+ mtime 0.1))))))
(loop (now) 0.0)