#!/usr/local/bin/movie_wish -f
#
# A simple demo of how the movie command can be used
#
#
#
#
# Author : Ian Campbell,   Ian.Campbell@ncl.ac.uk
# CopyRight see COPYRIGHT

#
# Set video1 to a mpeg file on your system
#


set video1 "/home/wilf/work/mpegproject/movies/niomi.mpg"
set stopped 1
set loop 0
set speed 30
set frameNum 0
frame .a

movie .a.s  -file $video1 -bd 3 -relief sunk 


button .b -text "play" -command { 
         if $stopped {
                       set stopped 0
                       tick
                     }
}
button .c -text "quit" -command quit
button .d -text "stop" -command {set stopped 1}
button .e -text "rewind" -command {.a.s rewind }
button .f -text "loop" -command { if $loop {
                                             set loop 0
					     .a.s configure -loop false
					     } else {
					     set loop 1
					     .a.s configure -loop true
						} }
label .g -textvariable frameNum -width 3

scale .a.speed -from 1 -to 300 -orient vertical -showvalue false -command "speedProc"
.a.speed set $speed
pack append .a .a.s {left expand fill} .a.speed {left filly expand}

pack append . .a {top expand fill}  .b {left expand fill} \
                                    .d {left expand fill} \
                                    .e {left expand fill} \
				    .f {left expand fill} \
				    .c {left expand fill} \
				    .g {left expand fill} 

bind .a.s <Button-1> { .a.s play 1}
bind .a.s <Double-Button-1> {.a.s play 25}


proc quit {} {

destroy .
}

proc tick {} {
    global stopped
    global speed 
    global frameNum
    if $stopped return
    after $speed tick
    
    .a.s play 1   
    set frameNum [.a.s framenumber]
}

proc speedProc value {
global speed
set speed $value
}
