逗人,視頻和音頻(IE)瀏覽器
我做了HTML幫手播放視頻和音頻
,當我從(7默認)改爲(9,10或邊緣),它確實能正常工作 我如何解決它是最新的。 我需要做什麼?
這是我的代碼助手
public static IHtmlString Media(this HtmlHelper helper, string width, string height, string src, bool isYoutubeOrVimeo = false, string type = "video")
{
if (type == "audio")
{
return new MvcHtmlString(string.Format(@"<audio controls>
<source src='{0}' type='audio/ogg'>
<source src='{0}' type='audio/mpeg'>
<source src='{0}' type='audio/wav'>
Your browser does not support the audio element.
</audio>", src));
}
else
{
if (isYoutubeOrVimeo == false)
{
return new MvcHtmlString(string.Format(@"<video width='{0}' height='{1}' controls>
<source src='{2}' type='video/mp4'>
<source src='{2}' type='video/ogg'>
<source src='{2}' type='video/webm'>
Your browser does not support the video tag.
</video>", width, height, src));
}
else
{
Regex VimeoVideoRegex = new Regex(@"vimeo\.com/(?:.*#|.*/videos/)?([0-9]+)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex YoutubeVideoRegex = new Regex(@"^(?:https?\:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v\=))([\w-]{10,12})(?:$|\&|\?\#).*");
Match youtubeMatch = YoutubeVideoRegex.Match(src);
Match vimeoMatch = VimeoVideoRegex.Match(src);
string id = string.Empty;
if (youtubeMatch.Success)
{
id = youtubeMatch.Groups[1].Value;
return new MvcHtmlString(string.Format(@"<iframe width='{0}' height='{1}' src='{2}' frameborder='0' allowfullscreen></iframe>", width, height, "https://www.youtube.com/embed/" + id));
}
if (vimeoMatch.Success)
id = vimeoMatch.Groups[1].Value;
return new MvcHtmlString(string.Format(@"<iframe width='{0}' height='{1}' src='{2}' frameborder='0'></iframe>", width, height, "https://player.vimeo.com/video/" + id));
}
}
}