mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
It now actually works. Also, MovieInWindow and VerySimplePlayer
example programs translated to python and added.
This commit is contained in:
parent
232f3cd190
commit
9cfea10bf2
6 changed files with 1147 additions and 870 deletions
71
Mac/Demo/quicktime/MovieInWindow.py
Normal file
71
Mac/Demo/quicktime/MovieInWindow.py
Normal file
|
|
@ -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()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue