Post a Reply
Movies and Menus
Subject: some isolations
Date: 2002-02-01 11:16:34
Response to: Thanks, some observations
I used the original nib file before I started messing with autoresizing.
I was able to comment out your file types and get some action.
Now, I've lost autoresizing code, for, when I try to use it, the movie window dissappears.
The best I can show you is the code with the resizing stuff commented out so the window doesn't dissappear. I don't know how to make a cleaner isolation or leaner question presentation than showing this.
NSArray *fileTypes = [NSArray arrayWithObjects:@"mov", @"mpg",
@"mp3", @"jpg", nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
int result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil types:fileTypes];
if (result == NSOKButton)
NSRect frameView = [movieView frame];
NSArray *movieToOpen = [oPanel URLs];
NSURL *movieURL = [movieToOpen objectAtIndex:0];
NSMovie *movie = [[NSMovie alloc] initWithURL:movieURL byReference:NO];
if you don't autorelease here, you'll have to do it later.
NSWindow *window = [NSApp mainWindow];
is strictly equivalent to this one:
NSWindow *movieWindow = [movieView window];
because there is only one window at a time, this is the main window and
there is an outlet defined in Controller.h: IBOutlet NSMovieView *movieView;
This outlet is connected from Controller to NSMovieView view.
[window setTitle:[[[oPanel filenames] objectAtIndex:0] lastPathComponent]];
You'll have to set the movie, before showing the controller, resizing the view, make it key and displaying it, otherwise, the controller could not show and the size could not be adjusted to your movie.
[movieView showController:YES adjustingSize:YES];//michele
Here comes the code for resizing window
In the nib file, do not set any springs to the custom view, because it would be applied when you resize together with the code for resizing. Then it'll be bloody.
For example: I've made the view in nib file: 20, 20 for margins 292, 203 for width and height
the window: 21, 53 for the margins 339, 243 for width and height
minimum size: 221, 153 maximum size: 800, 600
// Draw the movie at magnification 1
viewSize = [movieView sizeForMagnification:1.0];
viewSize.width = 2*frameView.origin.x + viewSize.width;
viewSize.height = 2*frameView.origin.y + viewSize.height;
[window makeKeyAndOrderFront: self];//michele
Hope this helps you