02.04.2013 Views

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C H A P T E R 3<br />

Extending the QT<strong>Kit</strong>Player Application<br />

if ([openPanel runModalForTypes:nil] == NSOKButton) {<br />

[self openDocumentWithContentsOfFile:[[openPanel filenames] lastObject]<br />

display:YES];<br />

}<br />

}<br />

17. Add the following lines of code:<br />

- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename<br />

{<br />

return (nil != [self openDocumentWithContentsOfFile:filename display:YES]);<br />

}<br />

18. Insert the following code to display the Print dialog:<br />

- (void)printShowingPrintPanel:(BOOL)showPanels<br />

{<br />

NSPrintOperation *printOperation;<br />

// init<br />

printOperation = [NSPrintOperation printOperationWithView:mMovieView<br />

printInfo:[self printInfo]];<br />

[printOperation setShowPanels:showPanels];<br />

// print<br />

[self runModalPrintOperation:printOperation delegate:nil didRunSelector:nil<br />

contextInfo:nil];<br />

}<br />

19. You add the following code to handle the NSSavePanel delegate for the export sheet. Note that<br />

you use an NSArray to list export types, such as mpg4, bmpf, aiff, and so on. These types are<br />

hard-coded here. You can add to the list if you want to and include, for example, 3gpp or mpg3.<br />

- (void)exportPanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode<br />

contextInfo:(void *)contextInfo<br />

{<br />

int selectedItem;<br />

NSMutableDictionary*settings = nil;<br />

static NSArray *exportTypes = nil;<br />

// init<br />

if (exportTypes == nil)<br />

{<br />

exportTypes = [[NSArray arrayWithObjects:<br />

[NSNumber numberWithLong:'AIFF'], [NSNumber numberWithLong:'BMPf'],<br />

[NSNumber numberWithLong:'dvc!'],<br />

[NSNumber numberWithLong:'FLC '], [NSNumber numberWithLong:'mpg4'],<br />

[NSNumber numberWithLong:'MooV'],<br />

[NSNumber numberWithLong:'embd'], nil] retain];<br />

}<br />

// export<br />

if (returnCode == NSOKButton)<br />

{<br />

// init<br />

selectedItem = [mExportTypePopUpButton indexOfSelectedItem];<br />

settings = [NSMutableDictionary dictionaryWithCapacity:5];<br />

[settings setObject:[NSNumber numberWithBool:YES] forKey:QTMovieExport];<br />

54 Adding Code to MovieDocument.m<br />

2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!