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 />
3. You also want to define the maximum number of URLs, in this case 15. Insert this line:<br />
#define kMaximumURLs 15<br />
4. Now you want to add the following class methods to deal with opening the URL panel. Add<br />
these lines:<br />
+ (id)openURLPanel<br />
{<br />
if (openURLPanel == nil)<br />
openURLPanel = [[self alloc] init];<br />
return openURLPanel;<br />
}<br />
5. Next, you need to add initialization code to initialize an OpenURLPanel instance and listen for<br />
application termination notifications. Add these lines:<br />
- (id)init<br />
{<br />
[super init];<br />
// init<br />
[self setURLArray:[NSMutableArray arrayWithCapacity:10];<br />
[[NSNotificationCenter defaultCenter] addObserver:self<br />
selector:@selector(writeURLs:) name:NSApplicationWillTerminateNotification<br />
object:NSApp];<br />
}<br />
return self;<br />
6. Insert the following code to handle deallocation of memory and notifications:<br />
- (void)dealloc<br />
{<br />
[[NSNotificationCenter defaultCenter] removeObserver:self];<br />
[self setURLArray:nil];<br />
[super dealloc];<br />
}<br />
7. To get the URL string, insert this chunk of code:<br />
- (NSString *)urlString<br />
{<br />
NSString *urlString = nil;<br />
}<br />
// get the url<br />
urlString = [mUrlComboBox stringValue];<br />
if (urlString == nil)<br />
urlString = [mUrlComboBox objectValueOfSelectedItem];<br />
if ([urlString length] == 0)<br />
urlString = nil;<br />
return urlString;<br />
90 Adding Code To Stream Audio and Video<br />
2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.