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