advertisement

Article:
  Movies and Menus
Subject:   FileTypes and resizing
Date:   2002-01-26 22:52:07
From:   dimamarkman
here is slightly modified version of openMovie,
that support HFS 'Moov" type and auto resizing
window


- (IBAction)openMovie:(id)sender
{
NSArray *fileTypes = [NSArray arrayWithObjects:@"mov", @"mpg", @"mp3",
@"jpg", @"swf",NSFileTypeForHFSTypeCode('MooV'),nil];

NSOpenPanel *oPanel = [NSOpenPanel openPanel];


int result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil types:fileTypes];

if (result == NSOKButton) {
NSWindow *window = [NSApp mainWindow];
NSRect frameView = [movieView frame];


NSSize viewSize;
NSArray *movieToOpen = [oPanel URLs];
NSURL *movieURL = [movieToOpen objectAtIndex:0];


NSMovie *movie = [[NSMovie alloc] initWithURL:movieURL byReference:NO];
[window setTitle:[[[oPanel filenames] objectAtIndex:0] lastPathComponent]];
[movieView setMovie:movie];
viewSize = [movieView sizeForMagnification:1.0];
[movieView resizeWithMagnification:1.0];
viewSize.width = 2*frameView.origin.x + viewSize.width;
viewSize.height = 2*frameView.origin.y + viewSize.height;
[window setContentSize:viewSize];
}
}