diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-12-09 14:05:56 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-12-09 14:05:56 (GMT) |
commit | 9cfea10bf2fbebd65a2f81e60bc48576c905ee9e (patch) | |
tree | fc00bb5ed9a16a9e76935ff81986474dfb277382 /Mac/Demo | |
parent | 232f3cd190720f2db408c5654a19496ba572c3fa (diff) | |
download | cpython-9cfea10bf2fbebd65a2f81e60bc48576c905ee9e.zip cpython-9cfea10bf2fbebd65a2f81e60bc48576c905ee9e.tar.gz cpython-9cfea10bf2fbebd65a2f81e60bc48576c905ee9e.tar.bz2 |
It now actually works. Also, MovieInWindow and VerySimplePlayer
example programs translated to python and added.
Diffstat (limited to 'Mac/Demo')
-rw-r--r-- | Mac/Demo/quicktime/MovieInWindow.py | 71 | ||||
-rw-r--r-- | Mac/Demo/quicktime/VerySimplePlayer.py | 97 |
2 files changed, 168 insertions, 0 deletions
diff --git a/Mac/Demo/quicktime/MovieInWindow.py b/Mac/Demo/quicktime/MovieInWindow.py new file mode 100644 index 0000000..8ff3b42 --- /dev/null +++ b/Mac/Demo/quicktime/MovieInWindow.py @@ -0,0 +1,71 @@ +"""MovieInWindow converted to python + +Jack Jansen, CWI, December 1995 +""" + +import addpack +addpack.addpack(':Tools:bgen:qt') +addpack.addpack(':Tools:bgen:qd') +addpack.addpack(':Tools:bgen:evt') +addpack.addpack(':Tools:bgen:win') +import Qt +import QuickTime +import Qd +import QuickDraw +import Evt +import Events +import Win +import Windows +import macfs +import sys + + +def main(): + # skip the toolbox initializations, already done + # XXXX Should use gestalt here to check for quicktime version + Qt.EnterMovies() + + # Get the movie file + fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType) + if not ok: + sys.exit(0) + + # Open the window + bounds = (175, 75, 175+160, 75+120) + theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 1, 0, -1, 0, 0) + Qd.SetPort(theWindow) + # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) + + playMovieInWindow(theWindow, fss, theWindow.GetWindowPort().portRect) + +def playMovieInWindow(theWindow, theFile, movieBox): + """Play a movie in a window""" + # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil); + + # Get the movie + theMovie = loadMovie(theFile) + + # Set where we want it + theMovie.SetMovieBox(movieBox) + + # Start at the beginning + theMovie.GoToBeginningOfMovie() + + # Give a little time to preroll + theMovie.MoviesTask(0) + + # Start playing + theMovie.StartMovie() + + while not theMovie.IsMovieDone() and not Evt.Button(): + theMovie.MoviesTask(0) + +def loadMovie(theFile): + """Load a movie given an fsspec. Return the movie object""" + movieResRef = Qt.OpenMovieFile(theFile, 1) + movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive) + return movie + +if __name__ == '__main__': + main() + diff --git a/Mac/Demo/quicktime/VerySimplePlayer.py b/Mac/Demo/quicktime/VerySimplePlayer.py new file mode 100644 index 0000000..24c97fb --- /dev/null +++ b/Mac/Demo/quicktime/VerySimplePlayer.py @@ -0,0 +1,97 @@ +"""VerySimplePlayer converted to python + +Jack Jansen, CWI, December 1995 +""" + +import addpack +addpack.addpack(':Tools:bgen:qt') +addpack.addpack(':Tools:bgen:qd') +addpack.addpack(':Tools:bgen:evt') +addpack.addpack(':Tools:bgen:win') +import Qt +import QuickTime +import Qd +import QuickDraw +import Evt +import Events +import Win +import Windows +import macfs +import sys + +# XXXX maxbounds = (40, 40, 1000, 1000) + +def main(): + print 'hello world' # XXXX + # skip the toolbox initializations, already done + # XXXX Should use gestalt here to check for quicktime version + Qt.EnterMovies() + + # Get the movie file + fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType) + if not ok: + sys.exit(0) + + # Open the window + bounds = (175, 75, 175+160, 75+120) + theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) + # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) + Qd.SetPort(theWindow) + + # Get the movie + theMovie = loadMovie(fss) + + # Relocate to (0, 0) + bounds = theMovie.GetMovieBox() + bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1] + theMovie.SetMovieBox(bounds) + + # Create a controller + theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) + + # Get movie size and update window parameters + rv, bounds = theController.MCGetControllerBoundsRect() + theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]? + Qt.AlignWindow(theWindow, 0) + theWindow.ShowWindow() + + # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds) + theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') + + # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow) + + done = 0 + while not done: + gotone, evt = Evt.WaitNextEvent(-1, 0) + (what, message, when, where, modifiers) = evt +## print what, message, when, where, modifiers # XXXX + + if theController.MCIsPlayerEvent(evt): + continue + + if what == Events.mouseDown: + part, whichWindow = Win.FindWindow(where) + if part == Windows.inGoAway: + done = whichWindow.TrackGoAway(where) + elif part == Windows.inDrag: + Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000)) + elif what == Events.updateEvt: + whichWindow = Win.WhichWindow(message) + if not whichWindow: + # Probably the console window. Print something, hope it helps. + print 'update' + else: + Qd.SetPort(whichWindow) + whichWindow.BeginUpdate() + Qd.EraseRect(whichWindow.GetWindowPort().portRect) + whichWindow.EndUpdate() + +def loadMovie(theFile): + """Load a movie given an fsspec. Return the movie object""" + movieResRef = Qt.OpenMovieFile(theFile, 1) + movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive) + return movie + +if __name__ == '__main__': + main() + |