blob: 8ff3b424dec3665f2df789381ba4b8dcc9b301e1 [file] [log] [blame]
Jack Jansen9cfea101995-12-09 14:05:56 +00001"""MovieInWindow converted to python
2
3Jack Jansen, CWI, December 1995
4"""
5
6import addpack
7addpack.addpack(':Tools:bgen:qt')
8addpack.addpack(':Tools:bgen:qd')
9addpack.addpack(':Tools:bgen:evt')
10addpack.addpack(':Tools:bgen:win')
11import Qt
12import QuickTime
13import Qd
14import QuickDraw
15import Evt
16import Events
17import Win
18import Windows
19import macfs
20import sys
21
22
23def main():
24 # skip the toolbox initializations, already done
25 # XXXX Should use gestalt here to check for quicktime version
26 Qt.EnterMovies()
27
28 # Get the movie file
29 fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType)
30 if not ok:
31 sys.exit(0)
32
33 # Open the window
34 bounds = (175, 75, 175+160, 75+120)
35 theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 1, 0, -1, 0, 0)
36 Qd.SetPort(theWindow)
37 # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
38
39 playMovieInWindow(theWindow, fss, theWindow.GetWindowPort().portRect)
40
41def playMovieInWindow(theWindow, theFile, movieBox):
42 """Play a movie in a window"""
43 # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil);
44
45 # Get the movie
46 theMovie = loadMovie(theFile)
47
48 # Set where we want it
49 theMovie.SetMovieBox(movieBox)
50
51 # Start at the beginning
52 theMovie.GoToBeginningOfMovie()
53
54 # Give a little time to preroll
55 theMovie.MoviesTask(0)
56
57 # Start playing
58 theMovie.StartMovie()
59
60 while not theMovie.IsMovieDone() and not Evt.Button():
61 theMovie.MoviesTask(0)
62
63def loadMovie(theFile):
64 """Load a movie given an fsspec. Return the movie object"""
65 movieResRef = Qt.OpenMovieFile(theFile, 1)
66 movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive)
67 return movie
68
69if __name__ == '__main__':
70 main()
71