ยปCore Development>Code coverage>Mac/Demo/quicktime/MovieInWindow.py

Python code coverage for Mac/Demo/quicktime/MovieInWindow.py

#countcontent
1n/a"""MovieInWindow converted to python
2n/a
3n/aJack Jansen, CWI, December 1995
4n/a"""
5n/a
6n/afrom Carbon import Qt
7n/afrom Carbon import QuickTime
8n/afrom Carbon import Qd
9n/afrom Carbon import QuickDraw
10n/afrom Carbon import Evt
11n/afrom Carbon import Events
12n/afrom Carbon import Win
13n/afrom Carbon import Windows
14n/afrom Carbon import File
15n/aimport EasyDialogs
16n/aimport sys
17n/aimport os
18n/a
19n/a
20n/adef main():
21n/a # skip the toolbox initializations, already done
22n/a # XXXX Should use gestalt here to check for quicktime version
23n/a Qt.EnterMovies()
24n/a
25n/a # Get the movie file
26n/a if len(sys.argv) > 1:
27n/a filename = sys.argv[1]
28n/a else:
29n/a filename = EasyDialogs.AskFileForOpen() # Was: QuickTime.MovieFileType
30n/a if not filename:
31n/a sys.exit(0)
32n/a
33n/a # Open the window
34n/a bounds = (175, 75, 175+160, 75+120)
35n/a theWindow = Win.NewCWindow(bounds, os.path.split(filename)[1], 1, 0, -1, 0, 0)
36n/a Qd.SetPort(theWindow)
37n/a # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
38n/a
39n/a playMovieInWindow(theWindow, filename, theWindow.GetWindowPort().GetPortBounds())
40n/a
41n/adef playMovieInWindow(theWindow, theFile, movieBox):
42n/a """Play a movie in a window"""
43n/a # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil);
44n/a
45n/a # Get the movie
46n/a theMovie = loadMovie(theFile)
47n/a
48n/a # Set where we want it
49n/a theMovie.SetMovieBox(movieBox)
50n/a
51n/a # Start at the beginning
52n/a theMovie.GoToBeginningOfMovie()
53n/a
54n/a # Give a little time to preroll
55n/a theMovie.MoviesTask(0)
56n/a
57n/a # Start playing
58n/a theMovie.StartMovie()
59n/a
60n/a while not theMovie.IsMovieDone() and not Evt.Button():
61n/a theMovie.MoviesTask(0)
62n/a
63n/adef loadMovie(theFile):
64n/a """Load a movie given an fsspec. Return the movie object"""
65n/a movieResRef = Qt.OpenMovieFile(theFile, 1)
66n/a movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive)
67n/a return movie
68n/a
69n/aif __name__ == '__main__':
70n/a main()