1 """VerySimplePlayer converted to python
3 Jack Jansen, CWI, December 1995
7 from Carbon
import QuickTime
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
18 # XXXX maxbounds = (40, 40, 1000, 1000)
21 print 'hello world' # XXXX
22 # skip the toolbox initializations, already done
23 # XXXX Should use gestalt here to check for quicktime version
27 fss
= EasyDialogs
.AskFileForOpen(wanted
=File
.FSSpec
) # Was: QuickTime.MovieFileType
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)
38 theMovie
= loadMovie(fss
)
41 bounds
= theMovie
.GetMovieBox()
42 bounds
= 0, 0, bounds
[2]-bounds
[0], bounds
[3]-bounds
[1]
43 theMovie
.SetMovieBox(bounds
)
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)
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
):
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
)
77 # Probably the console window. Print something, hope it helps.
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
)
91 if __name__
== '__main__':