+ // Adjust video size for auto-resizing within ranges minWidth and
+ // maxWidth.
+ if (widget.options.minWidth != 0 && widget.options.maxWidth != 0
+ && typeof widget.options.src == 'object'
+ && (typeof widget.options.src[ widget.options.srcIndex ].res)
+ != 'undefined'
+ && (typeof widget.options.src[ widget.options.srcIndex ].dar)
+ != 'undefined')
+ {
+ var resolution = widget.options.src[ widget.options.srcIndex ].res;
+ var dar = widget.options.src[ widget.options.srcIndex ].dar;
+ var darL = parseInt(
+ dar.substring(0, dar.indexOf(':')));
+ var darR = parseInt(
+ dar.substring(dar.indexOf(':') + 1));
+ var videoHeight = parseInt(
+ resolution.substring(resolution.indexOf('x') + 1));
+ var videoWidth = Math.round(videoHeight * darL / darR);
+ // Video width must be between minWidth and maxWidth pixels.
+ if (videoWidth > widget.options.maxWidth)
+ {
+ videoHeight = Math.round(widget.options.maxWidth / videoWidth
+ * videoHeight);
+ videoWidth = widget.options.maxWidth;
+ }
+ else if (videoWidth < widget.options.minWidth)
+ {
+ videoHeight = Math.round(widget.options.minWidth / videoWidth
+ * videoHeight);
+ videoWidth = widget.options.minWidth;
+ }
+ console.log(videoWidth + ' ' + videoHeight);
+ widget.$video.css('width', videoWidth);
+ widget.$video.css('height', videoHeight);
+ }
+