Skip to content
Browse files

disable YouTube auto-play by default; now requires an 'enableYouTubeA…

…utoPlay' default to work

(cherry picked from commit 28caabf)
  • Loading branch information...
1 parent 1f9d11d commit e69661cf71333bff1fee13c205a9d981b7b60c89 @simX simX committed
Showing with 15 additions and 5 deletions.
  1. +15 −5 Plugin/Plugin.m
View
20 Plugin/Plugin.m
@@ -55,6 +55,7 @@ of this software and associated documentation files (the "Software"), to deal
static NSString *sApplicationWhitelist = @"applicationWhitelist";
static NSString *sDrawGearImageOnlyOnMouseOverHiddenPref = @"drawGearImageOnlyOnMouseOver";
static NSString *sDisableVideoElement = @"disableVideoElement";
+static NSString *sYouTubeAutoPlay = @"enableYouTubeAutoPlay";
// Info.plist key for app developers
static NSString *sCTFOptOutKey = @"ClickToFlashOptOut";
@@ -211,11 +212,15 @@ - (id) initWithArguments:(NSDictionary *)arguments
if (_fromYouTube) {
// Check wether autoplay is wanted
- if ([[self host] isEqualToString:@"www.youtube.com"]
- || [[self host] isEqualToString:@"www.youtube-nocookie.com"]) {
- _youTubeAutoPlay = YES;
+ if ([[CTFUserDefaultsController standardUserDefaults] objectForKey:sYouTubeAutoPlay]) {
+ 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"];
+ }
} else {
- _youTubeAutoPlay = [[[self _flashVarDictionary:[self src]] objectForKey:@"autoplay"] isEqualToString:@"1"];
+ _youTubeAutoPlay = NO;
}
@@ -1382,6 +1387,8 @@ - (void) _convertElementForMP4: (DOMElement*) element
[ element setAttribute: @"scale" value: @"aspect" ];
if (_youTubeAutoPlay) {
[ element setAttribute: @"autoplay" value: @"true" ];
+ } else {
+ [ element setAttribute: @"autoplay" value: @"false" ];
}
[ element setAttribute: @"cache" value: @"false" ];
@@ -1399,7 +1406,10 @@ - (void) _convertElementForVideoElement: (DOMElement*) element
[ element setAttribute: @"src" value: [ self _h264VersionUrl ] ];
[ element setAttribute: @"autobuffer" value:@"autobuffer"];
if (_youTubeAutoPlay) {
- [ element setAttribute: @"autoplay" value:@"autoplay"];
+ [ element setAttribute: @"autoplay" value:@"autoplay" ];
+ } else {
+ if ( [element hasAttribute:@"autoplay"] )
+ [ element removeAttribute:@"autoplay" ];
}
[ element setAttribute: @"controls" value:@"controls"];

0 comments on commit e69661c

Please sign in to comment.
Something went wrong with that request. Please try again.