| 1 |
"""VerySimplePlayer converted to python |
| 2 |
|
| 3 |
Jack Jansen, CWI, December 1995 |
| 4 |
""" |
| 5 |
|
| 6 |
from Carbon import Qt |
| 7 |
from Carbon import QuickTime |
| 8 |
from Carbon import Qd |
| 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 |
| 15 |
import EasyDialogs |
| 16 |
import sys |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
def main(): |
| 21 |
print 'hello world' |
| 22 |
|
| 23 |
|
| 24 |
Qt.EnterMovies() |
| 25 |
|
| 26 |
|
| 27 |
fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) |
| 28 |
if not fss: |
| 29 |
sys.exit(0) |
| 30 |
|
| 31 |
|
| 32 |
bounds = (175, 75, 175+160, 75+120) |
| 33 |
theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) |
| 34 |
|
| 35 |
Qd.SetPort(theWindow) |
| 36 |
|
| 37 |
|
| 38 |
theMovie = loadMovie(fss) |
| 39 |
|
| 40 |
|
| 41 |
bounds = theMovie.GetMovieBox() |
| 42 |
bounds = 0, 0, bounds[2]-bounds[0], bounds[3]-bounds[1] |
| 43 |
theMovie.SetMovieBox(bounds) |
| 44 |
|
| 45 |
|
| 46 |
theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) |
| 47 |
|
| 48 |
|
| 49 |
rv, bounds = theController.MCGetControllerBoundsRect() |
| 50 |
theWindow.SizeWindow(bounds[2], bounds[3], 0) |
| 51 |
Qt.AlignWindow(theWindow, 0) |
| 52 |
theWindow.ShowWindow() |
| 53 |
|
| 54 |
|
| 55 |
theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
done = 0 |
| 60 |
while not done: |
| 61 |
gotone, evt = Evt.WaitNextEvent(0xffff, 0) |
| 62 |
(what, message, when, where, modifiers) = evt |
| 63 |
|
| 64 |
|
| 65 |
if theController.MCIsPlayerEvent(evt): |
| 66 |
continue |
| 67 |
|
| 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) |
| 76 |
if not whichWindow: |
| 77 |
|
| 78 |
print 'update' |
| 79 |
else: |
| 80 |
Qd.SetPort(whichWindow) |
| 81 |
whichWindow.BeginUpdate() |
| 82 |
Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds()) |
| 83 |
whichWindow.EndUpdate() |
| 84 |
|
| 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) |
| 89 |
return movie |
| 90 |
|
| 91 |
if __name__ == '__main__': |
| 92 |
main() |