Skip to content
Browse files

Possible fix for http://rentzsch.lighthouseapp.com/projects/24342/tic…

  • Loading branch information...
1 parent cdc99e5 commit ef9be0b8697a2c88f1eccc5be8502fec1511f07a @lapcat lapcat committed Sep 9, 2009
Showing with 20 additions and 7 deletions.
  1. +20 −7 Plugin/Plugin.m
View
27 Plugin/Plugin.m
@@ -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;
@@ -1160,7 +1161,7 @@ - (NSDictionary*) _flashVarDictionaryFromYouTubePageHTML: (NSString*) youTubePag
- (NSString*) flashvarWithName: (NSString*) argName
{
- return [ _flashVars objectForKey: argName ];
+ return [[[ _flashVars objectForKey: argName ] retain] autorelease];
}
/*- (NSString*) _videoId
@@ -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];
@@ -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];
@@ -1673,7 +1686,7 @@ - (void)setSrc:(NSString *)newValue
- (NSString *)videoId
{
- return _videoId;
+ return [[_videoId retain] autorelease];
}
- (void)setVideoId:(NSString *)newValue
{

0 comments on commit ef9be0b

Please sign in to comment.
Something went wrong with that request. Please try again.