@@ -119,6 +119,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
119
119
_hasHDH264Version = NO ;
120
120
_contextMenuIsVisible = NO ;
121
121
_embeddedYouTubeView = NO ;
122
+ _youTubeAutoPlay = NO ;
122
123
_delayingTimer = nil ;
123
124
defaultWhitelist = [NSArray arrayWithObjects: @" com.apple.frontrow" ,
124
125
@" com.apple.dashboard.client" ,
@@ -207,6 +208,16 @@ - (id) initWithArguments:(NSDictionary *)arguments
207
208
|| ([self src ] != nil && [[self src ] rangeOfString: @" youtube-nocookie.com" ].location != NSNotFound );
208
209
209
210
if (_fromYouTube) {
211
+
212
+ // Check wether autoplay is wanted
213
+ if ([[self host ] isEqualToString: @" www.youtube.com" ]
214
+ || [[self host ] isEqualToString: @" www.youtube-nocookie.com" ]) {
215
+ _youTubeAutoPlay = YES ;
216
+ } else {
217
+ _youTubeAutoPlay = [[[self _flashVarDictionary: [self src ]] objectForKey: @" autoplay" ] isEqualToString: @" 1" ];
218
+ }
219
+
220
+
210
221
NSString *videoId = [ self flashvarWithName: @" video_id" ];
211
222
if (videoId != nil ) {
212
223
[self setVideoId: videoId];
@@ -1339,7 +1350,9 @@ - (void) _convertElementForMP4: (DOMElement*) element
1339
1350
[ element setAttribute: @" src" value: [ self _h264VersionUrl ]];
1340
1351
[ element setAttribute: @" type" value: @" video/mp4" ];
1341
1352
[ element setAttribute: @" scale" value: @" aspect" ];
1342
- [ element setAttribute: @" autoplay" value: @" true" ];
1353
+ if (_youTubeAutoPlay) {
1354
+ [ element setAttribute: @" autoplay" value: @" true" ];
1355
+ }
1343
1356
[ element setAttribute: @" cache" value: @" false" ];
1344
1357
1345
1358
if ( ! [ element hasAttribute: @" width" ] )
@@ -1355,7 +1368,9 @@ - (void) _convertElementForVideoElement: (DOMElement*) element
1355
1368
{
1356
1369
[ element setAttribute: @" src" value: [ self _h264VersionUrl ] ];
1357
1370
[ element setAttribute: @" autobuffer" value: @" autobuffer" ];
1358
- [ element setAttribute: @" autoplay" value: @" autoplay" ];
1371
+ if (_youTubeAutoPlay) {
1372
+ [ element setAttribute: @" autoplay" value: @" autoplay" ];
1373
+ }
1359
1374
[ element setAttribute: @" controls" value: @" controls" ];
1360
1375
1361
1376
DOMElement * container = [self container ];
0 commit comments