Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…utoPlay' default to work
  • Loading branch information...
commit 28caabf43501a4733ba321e7815280477349ffe0 1 parent 1973fd1
Simone Manganelli simX authored

Showing 1 changed file with 15 additions and 5 deletions. Show diff stats Hide diff stats

  1. +15 5 Plugin/Plugin.m
20 Plugin/Plugin.m
@@ -55,6 +55,7 @@ of this software and associated documentation files (the "Software"), to deal
55 55 static NSString *sApplicationWhitelist = @"applicationWhitelist";
56 56 static NSString *sDrawGearImageOnlyOnMouseOverHiddenPref = @"drawGearImageOnlyOnMouseOver";
57 57 static NSString *sDisableVideoElement = @"disableVideoElement";
  58 +static NSString *sYouTubeAutoPlay = @"enableYouTubeAutoPlay";
58 59
59 60 // Info.plist key for app developers
60 61 static NSString *sCTFOptOutKey = @"ClickToFlashOptOut";
@@ -209,11 +210,15 @@ - (id) initWithArguments:(NSDictionary *)arguments
209 210 if (_fromYouTube) {
210 211
211 212 // Check wether autoplay is wanted
212   - if ([[self host] isEqualToString:@"www.youtube.com"]
213   - || [[self host] isEqualToString:@"www.youtube-nocookie.com"]) {
214   - _youTubeAutoPlay = YES;
  213 + if ([[CTFUserDefaultsController standardUserDefaults] objectForKey:sYouTubeAutoPlay]) {
  214 + if ([[self host] isEqualToString:@"www.youtube.com"]
  215 + || [[self host] isEqualToString:@"www.youtube-nocookie.com"]) {
  216 + _youTubeAutoPlay = YES;
  217 + } else {
  218 + _youTubeAutoPlay = [[[self _flashVarDictionary:[self src]] objectForKey:@"autoplay"] isEqualToString:@"1"];
  219 + }
215 220 } else {
216   - _youTubeAutoPlay = [[[self _flashVarDictionary:[self src]] objectForKey:@"autoplay"] isEqualToString:@"1"];
  221 + _youTubeAutoPlay = NO;
217 222 }
218 223
219 224
@@ -1414,6 +1419,8 @@ - (void) _convertElementForMP4: (DOMElement*) element atURL: (NSString*) URLStri
1414 1419 [ element setAttribute: @"scale" value: @"aspect" ];
1415 1420 if (_youTubeAutoPlay) {
1416 1421 [ element setAttribute: @"autoplay" value: @"true" ];
  1422 + } else {
  1423 + [ element setAttribute: @"autoplay" value: @"false" ];
1417 1424 }
1418 1425 [ element setAttribute: @"cache" value: @"false" ];
1419 1426
@@ -1431,7 +1438,10 @@ - (void) _convertElementForVideoElement: (DOMElement*) element atURL: (NSString*
1431 1438 [ element setAttribute: @"src" value: URLString ];
1432 1439 [ element setAttribute: @"autobuffer" value:@"autobuffer"];
1433 1440 if (_youTubeAutoPlay) {
1434   - [ element setAttribute: @"autoplay" value:@"autoplay"];
  1441 + [ element setAttribute: @"autoplay" value:@"autoplay" ];
  1442 + } else {
  1443 + if ( [element hasAttribute:@"autoplay"] )
  1444 + [ element removeAttribute:@"autoplay" ];
1435 1445 }
1436 1446 [ element setAttribute: @"controls" value:@"controls"];
1437 1447 // 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.