Graphics Reference
In-Depth Information
LISTING 8-6
Continued
float
vidHeight = [
self
frame
].
size
.
height
;
if
( [
videoPaths count
] >
kColCount
)
vidHeight = [
self
frame
].
size
.
height
/
(((
float
)[
videoPaths
count])/
kColCount
);
vidHeight = vidHeight -
kMargin
;
int
row = 0;
int
col = 0;
for
(i = 0; i < [
videoPaths count
]; ++i)
{
NSString
*path = [
videoPaths objectAtIndex
:i];
QTMovie
*m = [
QTMovie movieWithFile
:path
error
:
nil
];
// Mute each video
[m
setMuted
:
YES
];
// Force the movie to loop
[m
setAttribute
:[
NSNumber numberWithBool
:
YES
]
forKey
:
QTMovieLoopsAttribute
];
float
x = col*vidWidth;
float
y = row*vidHeight;
if
( i!= 0 && (i+1) % (
int
)
kColCount
== 0 )
{
row++;
}
CGRect
currentRect =
CGRectMake
(x+
kMargin
,
y+
kMargin
,
vidWidth-
kMargin
,
vidHeight-
kMargin
);
// Instantiate a video channel for each QTMovie
// object we've created
VideoChannel
*channel =
[[[
VideoChannel alloc
]
initWithMovie
:m
usingDisplayRect
:currentRect]
autorelease
];
[
videoChannels addObject
:channel];
col++;
if
( col >
kColCount
-1 )
col = 0;