Skip to content
Browse files

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

…utoPlay' default to work
  • Loading branch information...
1 parent 1973fd1 commit 28caabf43501a4733ba321e7815280477349ffe0 @simX simX committed Sep 19, 2009
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";
@@ -209,11 +210,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;
}
@@ -1414,6 +1419,8 @@ - (void) _convertElementForMP4: (DOMElement*) element atURL: (NSString*) URLStri
[ element setAttribute: @"scale" value: @"aspect" ];
if (_youTubeAutoPlay) {
[ element setAttribute: @"autoplay" value: @"true" ];
+ } else {
+ [ element setAttribute: @"autoplay" value: @"false" ];
}
[ element setAttribute: @"cache" value: @"false" ];
@@ -1431,7 +1438,10 @@ - (void) _convertElementForVideoElement: (DOMElement*) element atURL: (NSString*
[ element setAttribute: @"src" value: URLString ];
[ 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"];
// make videos with the wrong aspect ratio look more letterboxed. Would it be better or worse to just change the element's size?

0 comments on commit 28caabf

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