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