Skip to content
Browse files

Try to make the video view more flexible.

Such that resizing (e.g. on YouTube with the resize button or in separate windows spawned by YouTube) works.

No idea whether this is a good idea (yet), but it worked in the two cases I tried. Additional testing would be a good idea.
  • Loading branch information...
1 parent 78bc132 commit 9c98b0903006e113e941d72a05060cd5cb75a7b3 @ssp ssp committed Sep 20, 2009
Showing with 15 additions and 16 deletions.
  1. +15 −16 Plugin/Plugin.m
View
31 Plugin/Plugin.m
@@ -1403,13 +1403,7 @@ - (void) _convertElementForMP4: (DOMElement*) element atURL: (NSString*) URLStri
[ element setAttribute: @"autoplay" value: @"true" ];
}
[ element setAttribute: @"cache" value: @"false" ];
-
- if( ! [ element hasAttribute: @"width" ] )
- [ element setAttribute: @"width" value: @"640" ];
-
- if( ! [ element hasAttribute: @"height" ] )
- [ element setAttribute: @"height" value: @"500" ];
-
+ [ element setAttribute: @"bgcolor" value: @"transparent" ];
[ element setAttribute: @"flashvars" value: nil ];
}
@@ -1421,13 +1415,7 @@ - (void) _convertElementForVideoElement: (DOMElement*) element atURL: (NSString*
[ element setAttribute: @"autoplay" value:@"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?
- [ element setAttribute: @"style" value :@"background:#111"];
-
- DOMElement* container = [self container];
-
- [ element setAttribute:@"width" value:[ NSString stringWithFormat:@"%dpx", [ container clientWidth ]]];
- [ element setAttribute:@"height" value:[ NSString stringWithFormat:@"%dpx", [ container clientHeight ]]];
+ [ element setAttribute:@"width" value:@"100%"];
}
@@ -1502,8 +1490,19 @@ - (void) _convertToMP4ContainerAfterDelayUsingHD: (NSNumber*) useHDNumber
[extraDownloadLinkElement setTextContent: CtFLocalizedString(@"(Larger Size)", @"Text of link to additional Large Size H.264 Download appearing beneath the video after the standard link")];
[linkContainerElement appendChild: extraDownloadLinkElement];
}
-
- NSString * widthCSS = [NSString stringWithFormat:@"%@width:%dpx", divCSS, [[self container] clientWidth]];
+
+ DOMNode * widthNode = [[[self container] attributes ] getNamedItem:@"width"];
+ NSString * width = @"100%"; // default to 100% width
+ if (widthNode != nil) {
+ // width is already set explicitly, preserve that
+ width = [widthNode nodeValue];
+ if ( [[NSCharacterSet decimalDigitCharacterSet] characterIsMember:[width characterAtIndex:[width length] - 1]] ) {
+ // add 'px' if existing width is just a number (ends with a digit)
+ width = [width stringByAppendingString:@"px"];
+ }
+ }
+ NSString * widthCSS = [NSString stringWithFormat:@"%@width:%@;", divCSS, width];
+
DOMElement* CtFContainerElement = [document createElement: @"div"];
[CtFContainerElement setAttribute: @"style" value: widthCSS];
[CtFContainerElement setAttribute: @"class" value: @"clicktoflash-container"];

0 comments on commit 9c98b09

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