| 1 | n/a | """VerySimplePlayer converted to python |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | Jack Jansen, CWI, December 1995 |
|---|
| 4 | n/a | """ |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | from Carbon import Qt |
|---|
| 7 | n/a | from Carbon import QuickTime |
|---|
| 8 | n/a | from Carbon import Qd |
|---|
| 9 | n/a | from Carbon import QuickDraw |
|---|
| 10 | n/a | from Carbon import Evt |
|---|
| 11 | n/a | from Carbon import Events |
|---|
| 12 | n/a | from Carbon import Win |
|---|
| 13 | n/a | from Carbon import Windows |
|---|
| 14 | n/a | from Carbon import File |
|---|
| 15 | n/a | import EasyDialogs |
|---|
| 16 | n/a | import sys |
|---|
| 17 | n/a | |
|---|
| 18 | n/a | # XXXX maxbounds = (40, 40, 1000, 1000) |
|---|
| 19 | n/a | |
|---|
| 20 | n/a | def main(): |
|---|
| 21 | n/a | print 'hello world' # XXXX |
|---|
| 22 | n/a | # skip the toolbox initializations, already done |
|---|
| 23 | n/a | # XXXX Should use gestalt here to check for quicktime version |
|---|
| 24 | n/a | Qt.EnterMovies() |
|---|
| 25 | n/a | |
|---|
| 26 | n/a | # Get the movie file |
|---|
| 27 | n/a | fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) # Was: QuickTime.MovieFileType |
|---|
| 28 | n/a | if not fss: |
|---|
| 29 | n/a | sys.exit(0) |
|---|
| 30 | n/a | |
|---|
| 31 | n/a | # Open the window |
|---|
| 32 | n/a | bounds = (175, 75, 175+160, 75+120) |
|---|
| 33 | n/a | theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) |
|---|
| 34 | n/a | # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) |
|---|
| 35 | n/a | Qd.SetPort(theWindow) |
|---|
| 36 | n/a | |
|---|
| 37 | n/a | # Get the movie |
|---|
| 38 | n/a | theMovie = loadMovie(fss) |
|---|
| 39 | n/a | |
|---|
| 40 | n/a | # Relocate to (0, 0) |
|---|
| 41 | n/a | bounds = theMovie.GetMovieBox() |
|---|
| 42 | n/a | bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1] |
|---|
| 43 | n/a | theMovie.SetMovieBox(bounds) |
|---|
| 44 | n/a | |
|---|
| 45 | n/a | # Create a controller |
|---|
| 46 | n/a | theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | # Get movie size and update window parameters |
|---|
| 49 | n/a | rv, bounds = theController.MCGetControllerBoundsRect() |
|---|
| 50 | n/a | theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]? |
|---|
| 51 | n/a | Qt.AlignWindow(theWindow, 0) |
|---|
| 52 | n/a | theWindow.ShowWindow() |
|---|
| 53 | n/a | |
|---|
| 54 | n/a | # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds) |
|---|
| 55 | n/a | theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') |
|---|
| 56 | n/a | |
|---|
| 57 | n/a | # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow) |
|---|
| 58 | n/a | |
|---|
| 59 | n/a | done = 0 |
|---|
| 60 | n/a | while not done: |
|---|
| 61 | n/a | gotone, evt = Evt.WaitNextEvent(0xffff, 0) |
|---|
| 62 | n/a | (what, message, when, where, modifiers) = evt |
|---|
| 63 | n/a | ## print what, message, when, where, modifiers # XXXX |
|---|
| 64 | n/a | |
|---|
| 65 | n/a | if theController.MCIsPlayerEvent(evt): |
|---|
| 66 | n/a | continue |
|---|
| 67 | n/a | |
|---|
| 68 | n/a | if what == Events.mouseDown: |
|---|
| 69 | n/a | part, whichWindow = Win.FindWindow(where) |
|---|
| 70 | n/a | if part == Windows.inGoAway: |
|---|
| 71 | n/a | done = whichWindow.TrackGoAway(where) |
|---|
| 72 | n/a | elif part == Windows.inDrag: |
|---|
| 73 | n/a | Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000)) |
|---|
| 74 | n/a | elif what == Events.updateEvt: |
|---|
| 75 | n/a | whichWindow = Win.WhichWindow(message) |
|---|
| 76 | n/a | if not whichWindow: |
|---|
| 77 | n/a | # Probably the console window. Print something, hope it helps. |
|---|
| 78 | n/a | print 'update' |
|---|
| 79 | n/a | else: |
|---|
| 80 | n/a | Qd.SetPort(whichWindow) |
|---|
| 81 | n/a | whichWindow.BeginUpdate() |
|---|
| 82 | n/a | Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds()) |
|---|
| 83 | n/a | whichWindow.EndUpdate() |
|---|
| 84 | n/a | |
|---|
| 85 | n/a | def loadMovie(theFile): |
|---|
| 86 | n/a | """Load a movie given an fsspec. Return the movie object""" |
|---|
| 87 | n/a | movieResRef = Qt.OpenMovieFile(theFile, 1) |
|---|
| 88 | n/a | movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive) |
|---|
| 89 | n/a | return movie |
|---|
| 90 | n/a | |
|---|
| 91 | n/a | if __name__ == '__main__': |
|---|
| 92 | n/a | main() |
|---|