Skip to content

Commit ef9be0b

Browse files
committed
1 parent cdc99e5 commit ef9be0b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Plugin/Plugin.m

+20-7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ - (void) _loadContentForWindow: (NSNotification*) notification;
7979

8080
- (NSDictionary*) _flashVarDictionary: (NSString*) flashvarString;
8181
- (NSDictionary*) _flashVarDictionaryFromYouTubePageHTML: (NSString*) youTubePageHTML;
82+
- (void)_didRetrieveEmbeddedPlayerFlashVars:(NSDictionary *)flashVars;
8283
- (void)_getEmbeddedPlayerFlashVarsAndCheckForVariantsWithVideoId:(NSString *)videoId;
8384
- (NSString*) flashvarWithName: (NSString*) argName;
8485
- (void) _checkForH264VideoVariants;
@@ -1160,7 +1161,7 @@ - (NSDictionary*) _flashVarDictionaryFromYouTubePageHTML: (NSString*) youTubePag
11601161

11611162
- (NSString*) flashvarWithName: (NSString*) argName
11621163
{
1163-
return [ _flashVars objectForKey: argName ];
1164+
return [[[ _flashVars objectForKey: argName ] retain] autorelease];
11641165
}
11651166

11661167
/*- (NSString*) _videoId
@@ -1468,6 +1469,18 @@ - (IBAction)openFullscreenInQTPlayer:(id)sender;
14681469
[openInQTPlayerScript release];
14691470
}
14701471

1472+
- (void)_didRetrieveEmbeddedPlayerFlashVars:(NSDictionary *)flashVars
1473+
{
1474+
if (flashVars)
1475+
{
1476+
_flashVars = [flashVars retain];
1477+
NSString *videoId = [self flashvarWithName:@"video_id"];
1478+
[self setVideoId:videoId];
1479+
}
1480+
1481+
[self _checkForH264VideoVariants];
1482+
}
1483+
14711484
- (void)_retrieveEmbeddedPlayerFlashVarsAndCheckForVariantsWithVideoId:(NSString *)videoId
14721485
{
14731486
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -1478,13 +1491,13 @@ - (void)_retrieveEmbeddedPlayerFlashVarsAndCheckForVariantsWithVideoId:(NSString
14781491
NSString *pageSourceString = [NSString stringWithContentsOfURL:YouTubePageURL
14791492
usedEncoding:nil
14801493
error:&pageSourceError];
1481-
if (! pageSourceError) {
1482-
_flashVars = [[self _flashVarDictionaryFromYouTubePageHTML:pageSourceString] retain];
1483-
_videoId = [self flashvarWithName:@"video_id"];
1494+
NSDictionary *flashVars = nil;
1495+
if (pageSourceString && !pageSourceError) {
1496+
flashVars = [self _flashVarDictionaryFromYouTubePageHTML:pageSourceString];
14841497
}
14851498

1486-
[self performSelectorOnMainThread:@selector(_checkForH264VideoVariants)
1487-
withObject:nil
1499+
[self performSelectorOnMainThread:@selector(_didRetrieveEmbeddedPlayerFlashVars:)
1500+
withObject:flashVars
14881501
waitUntilDone:NO];
14891502

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

16741687
- (NSString *)videoId
16751688
{
1676-
return _videoId;
1689+
return [[_videoId retain] autorelease];
16771690
}
16781691
- (void)setVideoId:(NSString *)newValue
16791692
{

0 commit comments

Comments
 (0)