Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into roddi/master

  • Loading branch information...
commit e2d236c55479bc315aeaaa5e8f16812697e62719 2 parents 9ba9063 + e68d035
@rentzsch authored
Showing with 21 additions and 9 deletions.
  1. +21 −9 Plugin/Plugin.m
View
30 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];
@@ -1601,8 +1614,7 @@ - (WebView *)webView
}
- (void)setWebView:(WebView *)newValue
{
- [newValue retain];
- [_webView release];
+ // Not retained, because the WebView owns the plugin, so we'll get a retain cycle.
_webView = newValue;
}
@@ -1674,7 +1686,7 @@ - (void)setSrc:(NSString *)newValue
- (NSString *)videoId
{
- return _videoId;
+ return [[_videoId retain] autorelease];
}
- (void)setVideoId:(NSString *)newValue
{
Please sign in to comment.
Something went wrong with that request. Please try again.