1995-12-09 14:05:56 +00:00
|
|
|
"""MovieInWindow converted to python
|
|
|
|
|
|
|
|
Jack Jansen, CWI, December 1995
|
|
|
|
"""
|
|
|
|
|
2001-08-25 12:15:04 +00:00
|
|
|
from Carbon import Qt
|
|
|
|
from Carbon import QuickTime
|
|
|
|
from Carbon import Qd
|
|
|
|
from Carbon import QuickDraw
|
|
|
|
from Carbon import Evt
|
|
|
|
from Carbon import Events
|
|
|
|
from Carbon import Win
|
|
|
|
from Carbon import Windows
|
1995-12-09 14:05:56 +00:00
|
|
|
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
|
1998-07-22 13:35:31 +00:00
|
|
|
fss, ok = macfs.StandardGetFile() # Was: QuickTime.MovieFileType
|
1995-12-09 14:05:56 +00:00
|
|
|
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)
|
1997-04-09 15:54:54 +00:00
|
|
|
movie, d1, d2 = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive)
|
1995-12-09 14:05:56 +00:00
|
|
|
return movie
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
|