Skip to content

Commit c9e2bfa

Browse files
fppzddsimX
fppzdd
authored andcommitted
1 parent 669fb1c commit c9e2bfa

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Plugin/Plugin.h

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ THE SOFTWARE.
4343
BOOL _fromYouTube;
4444
BOOL _fromFlickr;
4545
BOOL _embeddedYouTubeView;
46+
BOOL _youTubeAutoPlay;
4647
BOOL _hasH264Version;
4748
BOOL _hasHDH264Version;
4849
WebView *_webView;

Plugin/Plugin.m

+17-2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
119119
_hasHDH264Version = NO;
120120
_contextMenuIsVisible = NO;
121121
_embeddedYouTubeView = NO;
122+
_youTubeAutoPlay = NO;
122123
_delayingTimer = nil;
123124
defaultWhitelist = [NSArray arrayWithObjects: @"com.apple.frontrow",
124125
@"com.apple.dashboard.client",
@@ -207,6 +208,16 @@ - (id) initWithArguments:(NSDictionary *)arguments
207208
|| ([self src] != nil && [[self src] rangeOfString: @"youtube-nocookie.com"].location != NSNotFound );
208209

209210
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+
210221
NSString *videoId = [ self flashvarWithName: @"video_id" ];
211222
if (videoId != nil) {
212223
[self setVideoId:videoId];
@@ -1339,7 +1350,9 @@ - (void) _convertElementForMP4: (DOMElement*) element
13391350
[ element setAttribute: @"src" value: [ self _h264VersionUrl ]];
13401351
[ element setAttribute: @"type" value: @"video/mp4" ];
13411352
[ element setAttribute: @"scale" value: @"aspect" ];
1342-
[ element setAttribute: @"autoplay" value: @"true" ];
1353+
if (_youTubeAutoPlay) {
1354+
[ element setAttribute: @"autoplay" value: @"true" ];
1355+
}
13431356
[ element setAttribute: @"cache" value: @"false" ];
13441357

13451358
if( ! [ element hasAttribute: @"width" ] )
@@ -1355,7 +1368,9 @@ - (void) _convertElementForVideoElement: (DOMElement*) element
13551368
{
13561369
[ element setAttribute: @"src" value: [ self _h264VersionUrl ] ];
13571370
[ element setAttribute: @"autobuffer" value:@"autobuffer"];
1358-
[ element setAttribute: @"autoplay" value:@"autoplay"];
1371+
if (_youTubeAutoPlay) {
1372+
[ element setAttribute: @"autoplay" value:@"autoplay"];
1373+
}
13591374
[ element setAttribute: @"controls" value:@"controls"];
13601375

13611376
DOMElement* container = [self container];

0 commit comments

Comments
 (0)