+
+ // BUG: this if is because of a NS-VLC bug.
+ if (widget.options.type != 'ns-vlc')
+ widget.$video.css('position', 'relative');
+
+ // Adjust video size for auto-resizing within ranges minWidth and
+ // maxWidth.
+ if ( (width == 0 || height == 0)
+ && (widget.options.minWidth != 0 && widget.options.maxWidth != 0
+ || this.options.type.indexOf('vlc') != -1) )
+ {
+ widget.adjustVideoSizeFromMeta();
+ }
+
+ // Initialize video plugin
+ widget.$video.ready(function() {
+ widget.videoPlugin('init');
+ });
+
+ widget._setWidgetWidth();
+ },
+
+ adjustVideoSizeFromMeta: function() {
+ var widget = this;
+
+ if (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 (widget.options.minWidth != 0 && widget.options.maxWidth != 0)
+ {
+ 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;
+ }
+ }
+
+ widget.$video.css('width', videoWidth);
+ widget.$video.css('height', videoHeight);
+ }
+ },
+
+ _setWidgetWidth: function() {
+ if (widget.$video.width() < 640)
+ {
+ widget.element.css('width',
+ 640 + 8 + 'px');
+ widget.$video.css('left',
+ Math.round(widget.$videoContainer.width()/2
+ - widget.$video.width()/2)
+ + 'px');
+ }
+ else
+ {
+ widget.element.css('width',
+ widget.$video.width() + 8 + 'px');
+ widget.$video.css('left', '0');
+ }
+
+ this._trigger('resize');