public static IHtmlContent BuildVideoTag(this Url url, string source, IDictionary <string, string> options = null)
{
if (options == null)
{
options = new Dictionary <string, string>();
}
source = VIDEO_EXTENSION_RE.Replace(source, "", 1);
if (string.IsNullOrEmpty(url.m_resourceType))
{
url.m_resourceType = "video";
}
var strArray = url.m_sourceTypes ?? DEFAULT_VIDEO_SOURCE_TYPES;
var str1 = FinalizePosterUrl(url, source);
if (!string.IsNullOrEmpty(str1))
{
options.Add("poster", str1);
}
var sb = new StringBuilder("<video");
var flag = strArray.Length > 1;
if (!flag)
{
var str2 = url.BuildUrl(source + "." + strArray[0]);
options.Add("src", str2);
}
else
{
url.BuildUrl(source);
}
if (options.ContainsKey("html_height"))
{
options["height"] = options.SliceValue("html_height");
}
else if (url.Transformation.HtmlHeight != null)
{
options["height"] = url.Transformation.HtmlHeight;
}
if (options.ContainsKey("html_width"))
{
options["width"] = options.SliceValue("html_width");
}
else if (url.Transformation.HtmlWidth != null)
{
options["width"] = url.Transformation.HtmlWidth;
}
foreach (var keyValuePair in options.OrderBy(x => x.Key))
{
sb.Append(" ").Append(keyValuePair.Key);
if (keyValuePair.Value != null)
{
sb.Append("='").Append(keyValuePair.Value).Append("'");
}
}
sb.Append(">");
if (flag)
{
foreach (var sourceType in strArray)
{
url.AppendVideoSources(sb, source, sourceType);
}
}
if (!string.IsNullOrEmpty(url.m_fallbackContent))
{
sb.Append(url.m_fallbackContent);
}
sb.Append("</video>");
return(new HtmlString(sb.ToString()));
}