File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import getopt
12from gl import *
23from GL import *
34from DEVICE import *
@@ -72,20 +73,35 @@ def playsound(af, spkr):
7273 spkr .writesamps (data )
7374
7475def main ():
75- foreground ()
76- if len (sys .argv ) > 1 :
77- filename = sys .argv [1 ]
76+ looping = 0
77+ packfactor = 0
78+ opts , args = getopt .getopt (sys .argv [1 :], 'p:l' )
79+ for opt , arg in opts :
80+ if opt = '-p' :
81+ packfactor = int (eval (arg ))
82+ elif opt = '-l' :
83+ looping = 1
84+ if args :
85+ filename = args [0 ]
7886 else :
7987 filename = 'film.video'
8088 f , w , h , pf = openvideo (filename )
81- if len (sys .argv ) > 2 :
82- audiofilename = sys .argv [2 ]
89+ if 0 < packfactor <> pf :
90+ w = w / pf * packfactor
91+ h = h / pf * packfactor
92+ pf = packfactor
93+ if args [1 :]:
94+ audiofilename = args [1 ]
8395 af = open (audiofilename , 'r' )
8496 spkr = openspkr ()
97+ afskip = 0
8598 if len (sys .argv ) > 3 :
86- af .seek (eval (sys .argv [3 ]))
99+ afskip = eval (sys .argv [3 ])
100+ if afskip > 0 :
101+ af .seek (afskip )
87102 else :
88103 af , spkr = None , None
104+ foreground ()
89105 prefsize (w ,h )
90106 win = winopen (filename )
91107 RGBmode ()
@@ -98,6 +114,8 @@ def main():
98114 epoch .epoch = time .millitimer ()
99115 nframe = 0
100116 tijd = 1
117+ if looping :
118+ looping = f .tell ()
101119 try :
102120 while 1 :
103121 if running :
@@ -114,6 +132,13 @@ def main():
114132 print 'Played' , nframe , 'frames at' ,
115133 print 0.1 * int (nframe * 10000.0 / (t - epoch .epoch )),
116134 print 'frames/sec'
135+ if looping :
136+ f .seek (looping )
137+ epoch .epoch = time .millitimer ()
138+ nframe = 0
139+ running = 1
140+ if af <> None :
141+ af .seek (afskip )
117142 if af <> None :
118143 playsound (af ,spkr )
119144 if not running or qtest ():
You can’t perform that action at this time.
0 commit comments