Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lapcat committed Sep 9, 2009
1 parent cdc99e5 commit ef9be0b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (void) _loadContentForWindow: (NSNotification*) notification;

- (NSDictionary*) _flashVarDictionary: (NSString*) flashvarString;
- (NSDictionary*) _flashVarDictionaryFromYouTubePageHTML: (NSString*) youTubePageHTML;
- (void)_didRetrieveEmbeddedPlayerFlashVars:(NSDictionary *)flashVars;
- (void)_getEmbeddedPlayerFlashVarsAndCheckForVariantsWithVideoId:(NSString *)videoId;
- (NSString*) flashvarWithName: (NSString*) argName;
- (void) _checkForH264VideoVariants;
Expand Down Expand Up @@ -1160,7 +1161,7 @@ - (NSDictionary*) _flashVarDictionaryFromYouTubePageHTML: (NSString*) youTubePag

- (NSString*) flashvarWithName: (NSString*) argName
{
return [ _flashVars objectForKey: argName ];
return [[[ _flashVars objectForKey: argName ] retain] autorelease];
}

/*- (NSString*) _videoId
Expand Down Expand Up @@ -1468,6 +1469,18 @@ - (IBAction)openFullscreenInQTPlayer:(id)sender;
[openInQTPlayerScript release];
}

- (void)_didRetrieveEmbeddedPlayerFlashVars:(NSDictionary *)flashVars
{
if (flashVars)
{
_flashVars = [flashVars retain];
NSString *videoId = [self flashvarWithName:@"video_id"];
[self setVideoId:videoId];
}

[self _checkForH264VideoVariants];
}

- (void)_retrieveEmbeddedPlayerFlashVarsAndCheckForVariantsWithVideoId:(NSString *)videoId
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Expand All @@ -1478,13 +1491,13 @@ - (void)_retrieveEmbeddedPlayerFlashVarsAndCheckForVariantsWithVideoId:(NSString
NSString *pageSourceString = [NSString stringWithContentsOfURL:YouTubePageURL
usedEncoding:nil
error:&pageSourceError];
if (! pageSourceError) {
_flashVars = [[self _flashVarDictionaryFromYouTubePageHTML:pageSourceString] retain];
_videoId = [self flashvarWithName:@"video_id"];
NSDictionary *flashVars = nil;
if (pageSourceString && !pageSourceError) {
flashVars = [self _flashVarDictionaryFromYouTubePageHTML:pageSourceString];
}

[self performSelectorOnMainThread:@selector(_checkForH264VideoVariants)
withObject:nil
[self performSelectorOnMainThread:@selector(_didRetrieveEmbeddedPlayerFlashVars:)
withObject:flashVars
waitUntilDone:NO];

[pool drain];
Expand Down Expand Up @@ -1673,7 +1686,7 @@ - (void)setSrc:(NSString *)newValue

- (NSString *)videoId
{
return _videoId;
return [[_videoId retain] autorelease];
}
- (void)setVideoId:(NSString *)newValue
{
Expand Down

0 comments on commit ef9be0b

Please sign in to comment.