Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit c9e2bfac1492618c4a92da298af4a4d051ef927f 1 parent 669fb1c
fppzdd authored simX committed
Showing with 18 additions and 2 deletions.
  1. +1 −0  Plugin/Plugin.h
  2. +17 −2 Plugin/Plugin.m
View
1  Plugin/Plugin.h
@@ -43,6 +43,7 @@ THE SOFTWARE.
BOOL _fromYouTube;
BOOL _fromFlickr;
BOOL _embeddedYouTubeView;
+ BOOL _youTubeAutoPlay;
BOOL _hasH264Version;
BOOL _hasHDH264Version;
WebView *_webView;
View
19 Plugin/Plugin.m
@@ -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];
Please sign in to comment.
Something went wrong with that request. Please try again.