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