QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
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 5<br />
Extending the QT<strong>Kit</strong>Player To Stream Audio and Video<br />
8. To set the instance variable of the URL array, add the following code:<br />
- (void)setURLArray:(NSMutableArray *)urlLArray<br />
{<br />
[urlLArray retain];<br />
[mUrlLArray retain];<br />
mUrlLArray = urlLArray;<br />
}<br />
9. The next block of code lets you restore the previous URLs. Insert the following block of code:<br />
- (void)awakeFromNib<br />
{<br />
NSArray *urls;<br />
// restore the previous urls<br />
urls = [[NSUserDefaults standardUserDefaults]<br />
objectForKey:kUserDefaultURLsKey];<br />
[mUrlArray addObjectsFromArray:urls];<br />
if (urls)<br />
[mUrlComboBox addItemsWithObjectValues:urls];<br />
}<br />
10. To set up deal with notifications, you need to add this chunk of code. This will enable you to<br />
“listen” for any notifications. Insert the following:<br />
- (void)writeURLs:(NSNotification *)notification<br />
{<br />
}<br />
NSUserDefaults *userDefaults;<br />
if ([mUrlArray count]<br />
{<br />
// init<br />
userDefaults = [NSUserDefaults standardUserDefaults];<br />
// write out the urls<br />
[userDefaults setObject:mUrlArray forKey:kUserDefaultURLsKey];<br />
[userDefaults synchronize];<br />
}<br />
11. To write to actions, validate and save the URL, add the following code:<br />
- (IBAction)doOpenURL:(id)sender<br />
{<br />
{<br />
NSString*urlString;<br />
NSURL*url;<br />
BOOLinformDelegate = YES;<br />
IMP callback;<br />
if ([sender tag] == NSOKButton)<br />
{<br />
// validate the URL<br />
url = [self url];<br />
urlString = [self urlString];<br />
Adding Code To Stream Audio and Video 91<br />
2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.