12 global _moviesinitialized
13 if not _moviesinitialized
:
15 _moviesinitialized
= 1
17 class Movie(W
.Widget
):
19 def __init__(self
, possize
):
23 W
.Widget
.__init
__(self
, possize
)
25 def adjust(self
, oldbounds
):
27 Win
.InvalRect(oldbounds
)
28 Win
.InvalRect(self
._bounds
)
31 def set(self
, path_or_fss
, start
= 0):
34 #Win.InvalRect(self.movie.GetMovieBox())
35 Qd
.PaintRect(self
.movie
.GetMovieBox())
36 if type(path_or_fss
) == type(''):
38 fss
= macfs
.FSSpec(path
)
40 path
= path_or_fss
.as_pathname()
42 self
.movietitle
= os
.path
.basename(path
)
43 movieResRef
= Qt
.OpenMovieFile(fss
, 1)
44 self
.movie
, dummy
, dummy
= Qt
.NewMovieFromFile(movieResRef
, 0, QuickTime
.newMovieActive
)
45 self
.moviebox
= self
.movie
.GetMovieBox()
47 Qd
.ObscureCursor() # XXX does this work at all?
48 self
.movie
.GoToBeginningOfMovie()
50 self
.movie
.StartMovie()
54 self
.movie
.MoviesTask(0)
59 def getmovietitle(self
):
60 return self
.movietitle
65 self
.movie
.StartMovie()
70 self
.movie
.StopMovie()
75 self
.movie
.GoToBeginningOfMovie()
77 def calcmoviebox(self
):
80 ml
, mt
, mr
, mb
= self
.moviebox
81 wl
, wt
, wr
, wb
= widgetbox
= self
._bounds
86 if (mheight
* 2 < wheight
) and (mwidth
* 2 < wwidth
):
88 elif mheight
> wheight
or mwidth
> wwidth
:
89 scale
= min(float(wheight
) / mheight
, float(wwidth
) / mwidth
)
92 mwidth
, mheight
= mwidth
* scale
, mheight
* scale
93 ml
, mt
= wl
+ (wwidth
- mwidth
) / 2, wt
+ (wheight
- mheight
) / 2
94 mr
, mb
= ml
+ mwidth
, mt
+ mheight
95 self
.movie
.SetMovieBox((ml
, mt
, mr
, mb
))
97 def idle(self
, *args
):
99 if not self
.movie
.IsMovieDone() and self
.running
:
102 self
.movie
.MoviesTask(0)
103 gotone
, event
= Evt
.EventAvail(Events
.everyEvent
)
104 if gotone
or self
.movie
.IsMovieDone():
107 box
= self
.movie
.GetMovieBox()
113 def draw(self
, visRgn
= None):
115 Qd
.PaintRect(self
._bounds
)
117 self
.movie
.UpdateMovie()
118 self
.movie
.MoviesTask(0)