Restrict to sane number of types, with sane defaults

This commit is contained in:
Matthias Neeracher 2011-08-14 22:37:23 +02:00
parent d24a3e783d
commit 514fffddbd

View File

@ -139,10 +139,21 @@
[exportMovie writeToFile:[url path] withAttributes:attributes];
}
#define kMAAudioTypes @"m4a", @"aiff", @"aif", @"wav", @"caf", @"mp3"
#define kMAVideoTypes @"mov", @"mp4"
- (IBAction)exportMedia:(id)sender
{
QTMovie * currentMovie = [self currentMovie];
NSSavePanel * savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:[QTMovie movieFileTypes:QTIncludeCommonTypes]];
NSDictionary *attrs = [currentMovie movieAttributes];
BOOL hasVideo = [[attrs objectForKey:QTMovieHasVideoAttribute] boolValue];
BOOL hasAudio = !hasVideo || [[attrs objectForKey:QTMovieHasAudioAttribute] boolValue];
[savePanel setAllowedFileTypes:(hasVideo
? (hasAudio
? [NSArray arrayWithObjects: kMAVideoTypes, kMAAudioTypes, nil]
: [NSArray arrayWithObjects: kMAVideoTypes, nil])
: [NSArray arrayWithObjects: kMAAudioTypes, nil])];
[savePanel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result) {
[savePanel orderOut:self];
if (result == NSFileHandlingPanelOKButton)