Permalink
Browse files

This should fix http://rentzsch.lighthouseapp.com/projects/24342/tick…

  • Loading branch information...
1 parent 669fb1c commit c9e2bfac1492618c4a92da298af4a4d051ef927f fppzdd committed with simX Sep 15, 2009
Showing with 18 additions and 2 deletions.
  1. +1 −0 Plugin/Plugin.h
  2. +17 −2 Plugin/Plugin.m
View
@@ -43,6 +43,7 @@ THE SOFTWARE.
BOOL _fromYouTube;
BOOL _fromFlickr;
BOOL _embeddedYouTubeView;
+ BOOL _youTubeAutoPlay;
BOOL _hasH264Version;
BOOL _hasHDH264Version;
WebView *_webView;
View
@@ -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",
@@ -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];
@@ -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" ] )
@@ -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];

0 comments on commit c9e2bfa

Please sign in to comment.