blob: 2930eac7782627dfef815e676da87ffc01326059 [file] [log] [blame]
Jack Jansen9cfea101995-12-09 14:05:56 +00001"""VerySimplePlayer converted to python
2
3Jack Jansen, CWI, December 1995
4"""
5
Jack Jansen5a6fdcd2001-08-25 12:15:04 +00006from Carbon import Qt
7from Carbon import QuickTime
8from Carbon import Qd
9from Carbon import QuickDraw
10from Carbon import Evt
11from Carbon import Events
12from Carbon import Win
13from Carbon import Windows
Jack Jansenb340acf2003-01-26 21:40:00 +000014from Carbon import File
15import EasyDialogs
Jack Jansen9cfea101995-12-09 14:05:56 +000016import sys
17
18# XXXX maxbounds = (40, 40, 1000, 1000)
19
20def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000021 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()
25
26 # Get the movie file
27 fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) # Was: QuickTime.MovieFileType
28 if not fss:
29 sys.exit(0)
30
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)
36
37 # Get the movie
38 theMovie = loadMovie(fss)
39
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)
44
45 # Create a controller
46 theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie)
47
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()
53
54 # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds)
55 theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1')
56
57 # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow)
58
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
64
65 if theController.MCIsPlayerEvent(evt):
66 continue
67
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()
84
Jack Jansen9cfea101995-12-09 14:05:56 +000085def loadMovie(theFile):
Tim Peters182b5ac2004-07-18 06:16:08 +000086 """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
90
Jack Jansen9cfea101995-12-09 14:05:56 +000091if __name__ == '__main__':
Tim Peters182b5ac2004-07-18 06:16:08 +000092 main()