QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
C H A P T E R 5<br />
Extending the QT<strong>Kit</strong>Player To Stream Audio and Video<br />
BOOL closePanel = YES;<br />
// create the movie document<br />
if (returnCode == NSOKButton)<br />
closePanel = [self createMovieDocumentWithURL:[openURLPanel url]<br />
asData:((long)contextInfo == kQT<strong>Kit</strong>PlayerOpenAsData)];<br />
}<br />
if (closePanel)<br />
[openURLPanel close];<br />
6. Insert the following code to handle the necessary actions for opening the sheet with a window:<br />
- (IBAction)doOpenURL:(id)sender<br />
{<br />
[[OpenURLPanel openURLPanel] beginSheetWithWindow:nil delegate:self<br />
didEndSelector:@selector(openURLPanelDidEnd:returnCode:contextInfo:)<br />
contextInfo:((void *)kQT<strong>Kit</strong>PlayerOpenAsURL)];<br />
}<br />
- (IBAction)doOpenURLData:(id)sender<br />
{<br />
[[OpenURLPanel openURLPanel] beginSheetWithWindow:nil delegate:self<br />
didEndSelector:@selector(openURLPanelDidEnd:returnCode:contextInfo:)<br />
contextInfo:((void *)kQT<strong>Kit</strong>PlayerOpenAsData)];<br />
}<br />
7. These are the methods you need to create and set up the movie document with an associated<br />
URL. Insert this chunk of code:<br />
- (BOOL)createMovieDocumentWithURL:(NSURL *)url asData:(BOOL)asData<br />
{<br />
NSDocument *movieDocument = nil;<br />
NSDocumentController*documentController;<br />
BOOL success = YES;<br />
// init<br />
documentController = [NSDocumentController sharedDocumentController];<br />
// try to create the document from the URL<br />
if (url)<br />
{<br />
if (asData)<br />
movieDocument = [documentController makeDocumentWithContentsOfURL:url<br />
ofType:@"MovieDocumentData"];<br />
else<br />
movieDocument = [documentController makeDocumentWithContentsOfURL:url<br />
ofType:@"MovieDocument"];<br />
}<br />
// add the document<br />
if (movieDocument)<br />
{<br />
[documentController addDocument:movieDocument];<br />
// setup<br />
[movieDocument makeWindowControllers];<br />
[movieDocument updateChangeCount:NSChangeCleared];<br />
96 Adding Code To Stream Audio and Video<br />
2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.