4 from Carbon
import Qt
, QuickTime
6 from Carbon
import File
7 from Carbon
import Evt
, Events
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 self
.GetWindow().InvalWindowRect(oldbounds
)
28 self
.GetWindow().InvalWindowRect(self
._bounds
)
31 def set(self
, path_or_fss
, start
= 0):
34 #self.GetWindow().InvalWindowRect(self.movie.GetMovieBox())
35 Qd
.PaintRect(self
.movie
.GetMovieBox())
36 path
= File
.pathname(path
)
37 self
.movietitle
= os
.path
.basename(path
)
38 movieResRef
= Qt
.OpenMovieFile(path_or_fss
, 1)
39 self
.movie
, dummy
, dummy
= Qt
.NewMovieFromFile(movieResRef
, 0, QuickTime
.newMovieActive
)
40 self
.moviebox
= self
.movie
.GetMovieBox()
42 Qd
.ObscureCursor() # XXX does this work at all?
43 self
.movie
.GoToBeginningOfMovie()
45 self
.movie
.StartMovie()
49 self
.movie
.MoviesTask(0)
54 def getmovietitle(self
):
55 return self
.movietitle
60 self
.movie
.StartMovie()
65 self
.movie
.StopMovie()
70 self
.movie
.GoToBeginningOfMovie()
72 def calcmoviebox(self
):
75 ml
, mt
, mr
, mb
= self
.moviebox
76 wl
, wt
, wr
, wb
= widgetbox
= self
._bounds
81 if (mheight
* 2 < wheight
) and (mwidth
* 2 < wwidth
):
83 elif mheight
> wheight
or mwidth
> wwidth
:
84 scale
= min(float(wheight
) / mheight
, float(wwidth
) / mwidth
)
87 mwidth
, mheight
= mwidth
* scale
, mheight
* scale
88 ml
, mt
= wl
+ (wwidth
- mwidth
) / 2, wt
+ (wheight
- mheight
) / 2
89 mr
, mb
= ml
+ mwidth
, mt
+ mheight
90 self
.movie
.SetMovieBox((ml
, mt
, mr
, mb
))
92 def idle(self
, *args
):
94 if not self
.movie
.IsMovieDone() and self
.running
:
97 self
.movie
.MoviesTask(0)
98 gotone
, event
= Evt
.EventAvail(Events
.everyEvent
)
99 if gotone
or self
.movie
.IsMovieDone():
102 box
= self
.movie
.GetMovieBox()
104 self
.GetWindow().InvalWindowRect(box
)
108 def draw(self
, visRgn
= None):
110 Qd
.PaintRect(self
._bounds
)
112 self
.movie
.UpdateMovie()
113 self
.movie
.MoviesTask(0)