Debian Codegraph @

cpython27/Mac/Demo/quicktime/MovieInWindow.py

raw symbols SCIP
1 """MovieInWindow converted to python
2
3 Jack Jansen, CWI, December 1995
4 """
5
6 from Carbon import Qt
7 from Carbon import QuickTime
8 from Carbon import Qd
9 from Carbon import QuickDraw
10 from Carbon import Evt
11 from Carbon import Events
12 from Carbon import Win
13 from Carbon import Windows
14 from Carbon import File
15 import EasyDialogs
16 import sys
17 import os
18
19
20 def main():
21 # skip the toolbox initializations, already done
22 # XXXX Should use gestalt here to check for quicktime version
23 Qt.EnterMovies()
24
25 # Get the movie file
26 if len(sys.argv) > 1:
27 filename = sys.argv[1]
28 else:
29 filename = EasyDialogs.AskFileForOpen() # Was: QuickTime.MovieFileType
30 if not filename:
31 sys.exit(0)
32
33 # Open the window
34 bounds = (175, 75, 175+160, 75+120)
35 theWindow = Win.NewCWindow(bounds, os.path.split(filename)[1], 1, 0, -1, 0, 0)
36 Qd.SetPort(theWindow)
37 # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
38
39 playMovieInWindow(theWindow, filename, theWindow.GetWindowPort().GetPortBounds())
40
41 def 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
63 def loadMovie(theFile):
64 """Load a movie given an fsspec. Return the movie object"""
65 movieResRef = Qt.OpenMovieFile(theFile, 1)
66 movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive)
67 return movie
68
69 if __name__ == '__main__':
70 main()