Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fppzdd authored and simX committed Oct 1, 2009
1 parent 669fb1c commit c9e2bfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions Plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ THE SOFTWARE.
BOOL _fromYouTube;
BOOL _fromFlickr;
BOOL _embeddedYouTubeView;
BOOL _youTubeAutoPlay;
BOOL _hasH264Version;
BOOL _hasHDH264Version;
WebView *_webView;
Expand Down
19 changes: 17 additions & 2 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
_hasHDH264Version = NO;
_contextMenuIsVisible = NO;
_embeddedYouTubeView = NO;
_youTubeAutoPlay = NO;
_delayingTimer = nil;
defaultWhitelist = [NSArray arrayWithObjects: @"com.apple.frontrow",
@"com.apple.dashboard.client",
Expand Down Expand Up @@ -207,6 +208,16 @@ - (id) initWithArguments:(NSDictionary *)arguments
|| ([self src] != nil && [[self src] rangeOfString: @"youtube-nocookie.com"].location != NSNotFound );

if (_fromYouTube) {

// Check wether autoplay is wanted
if ([[self host] isEqualToString:@"www.youtube.com"]
|| [[self host] isEqualToString:@"www.youtube-nocookie.com"]) {
_youTubeAutoPlay = YES;
} else {
_youTubeAutoPlay = [[[self _flashVarDictionary:[self src]] objectForKey:@"autoplay"] isEqualToString:@"1"];
}


NSString *videoId = [ self flashvarWithName: @"video_id" ];
if (videoId != nil) {
[self setVideoId:videoId];
Expand Down Expand Up @@ -1339,7 +1350,9 @@ - (void) _convertElementForMP4: (DOMElement*) element
[ element setAttribute: @"src" value: [ self _h264VersionUrl ]];
[ element setAttribute: @"type" value: @"video/mp4" ];
[ element setAttribute: @"scale" value: @"aspect" ];
[ element setAttribute: @"autoplay" value: @"true" ];
if (_youTubeAutoPlay) {
[ element setAttribute: @"autoplay" value: @"true" ];
}
[ element setAttribute: @"cache" value: @"false" ];

if( ! [ element hasAttribute: @"width" ] )
Expand All @@ -1355,7 +1368,9 @@ - (void) _convertElementForVideoElement: (DOMElement*) element
{
[ element setAttribute: @"src" value: [ self _h264VersionUrl ] ];
[ element setAttribute: @"autobuffer" value:@"autobuffer"];
[ element setAttribute: @"autoplay" value:@"autoplay"];
if (_youTubeAutoPlay) {
[ element setAttribute: @"autoplay" value:@"autoplay"];
}
[ element setAttribute: @"controls" value:@"controls"];

DOMElement* container = [self container];
Expand Down

0 comments on commit c9e2bfa

Please sign in to comment.