Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9cfea10

Browse files
committed
It now actually works. Also, MovieInWindow and VerySimplePlayer
example programs translated to python and added.
1 parent 232f3cd commit 9cfea10

6 files changed

Lines changed: 3985 additions & 3708 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""MovieInWindow converted to python
2+
3+
Jack Jansen, CWI, December 1995
4+
"""
5+
6+
import addpack
7+
addpack.addpack(':Tools:bgen:qt')
8+
addpack.addpack(':Tools:bgen:qd')
9+
addpack.addpack(':Tools:bgen:evt')
10+
addpack.addpack(':Tools:bgen:win')
11+
import Qt
12+
import QuickTime
13+
import Qd
14+
import QuickDraw
15+
import Evt
16+
import Events
17+
import Win
18+
import Windows
19+
import macfs
20+
import sys
21+
22+
23+
def main():
24+
# skip the toolbox initializations, already done
25+
# XXXX Should use gestalt here to check for quicktime version
26+
Qt.EnterMovies()
27+
28+
# Get the movie file
29+
fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType)
30+
if not ok:
31+
sys.exit(0)
32+
33+
# Open the window
34+
bounds = (175, 75, 175+160, 75+120)
35+
theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 1, 0, -1, 0, 0)
36+
Qd.SetPort(theWindow)
37+
# XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
38+
39+
playMovieInWindow(theWindow, fss, theWindow.GetWindowPort().portRect)
40+
41+
def playMovieInWindow(theWindow, theFile, movieBox):
42+
"""Play a movie in a window"""
43+
# XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil);
44+
45+
# Get the movie
46+
theMovie = loadMovie(theFile)
47+
48+
# Set where we want it
49+
theMovie.SetMovieBox(movieBox)
50+
51+
# Start at the beginning
52+
theMovie.GoToBeginningOfMovie()
53+
54+
# Give a little time to preroll
55+
theMovie.MoviesTask(0)
56+
57+
# Start playing
58+
theMovie.StartMovie()
59+
60+
while not theMovie.IsMovieDone() and not Evt.Button():
61+
theMovie.MoviesTask(0)
62+
63+
def loadMovie(theFile):
64+
"""Load a movie given an fsspec. Return the movie object"""
65+
movieResRef = Qt.OpenMovieFile(theFile, 1)
66+
movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive)
67+
return movie
68+
69+
if __name__ == '__main__':
70+
main()
71+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"""VerySimplePlayer converted to python
2+
3+
Jack Jansen, CWI, December 1995
4+
"""
5+
6+
import addpack
7+
addpack.addpack(':Tools:bgen:qt')
8+
addpack.addpack(':Tools:bgen:qd')
9+
addpack.addpack(':Tools:bgen:evt')
10+
addpack.addpack(':Tools:bgen:win')
11+
import Qt
12+
import QuickTime
13+
import Qd
14+
import QuickDraw
15+
import Evt
16+
import Events
17+
import Win
18+
import Windows
19+
import macfs
20+
import sys
21+
22+
# XXXX maxbounds = (40, 40, 1000, 1000)
23+
24+
def main():
25+
print 'hello world' # XXXX
26+
# skip the toolbox initializations, already done
27+
# XXXX Should use gestalt here to check for quicktime version
28+
Qt.EnterMovies()
29+
30+
# Get the movie file
31+
fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType)
32+
if not ok:
33+
sys.exit(0)
34+
35+
# Open the window
36+
bounds = (175, 75, 175+160, 75+120)
37+
theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0)
38+
# XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
39+
Qd.SetPort(theWindow)
40+
41+
# Get the movie
42+
theMovie = loadMovie(fss)
43+
44+
# Relocate to (0, 0)
45+
bounds = theMovie.GetMovieBox()
46+
bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1]
47+
theMovie.SetMovieBox(bounds)
48+
49+
# Create a controller
50+
theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie)
51+
52+
# Get movie size and update window parameters
53+
rv, bounds = theController.MCGetControllerBoundsRect()
54+
theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]?
55+
Qt.AlignWindow(theWindow, 0)
56+
theWindow.ShowWindow()
57+
58+
# XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds)
59+
theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1')
60+
61+
# XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow)
62+
63+
done = 0
64+
while not done:
65+
gotone, evt = Evt.WaitNextEvent(-1, 0)
66+
(what, message, when, where, modifiers) = evt
67+
## print what, message, when, where, modifiers # XXXX
68+
69+
if theController.MCIsPlayerEvent(evt):
70+
continue
71+
72+
if what == Events.mouseDown:
73+
part, whichWindow = Win.FindWindow(where)
74+
if part == Windows.inGoAway:
75+
done = whichWindow.TrackGoAway(where)
76+
elif part == Windows.inDrag:
77+
Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000))
78+
elif what == Events.updateEvt:
79+
whichWindow = Win.WhichWindow(message)
80+
if not whichWindow:
81+
# Probably the console window. Print something, hope it helps.
82+
print 'update'
83+
else:
84+
Qd.SetPort(whichWindow)
85+
whichWindow.BeginUpdate()
86+
Qd.EraseRect(whichWindow.GetWindowPort().portRect)
87+
whichWindow.EndUpdate()
88+
89+
def loadMovie(theFile):
90+
"""Load a movie given an fsspec. Return the movie object"""
91+
movieResRef = Qt.OpenMovieFile(theFile, 1)
92+
movie, dummy = Qt.NewMovieFromFile(movieResRef, QuickTime.newMovieActive)
93+
return movie
94+
95+
if __name__ == '__main__':
96+
main()
97+

0 commit comments

Comments
 (0)