2017-03-05 142 views
0

逗人,視頻和音頻(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)); 
       } 
      } 
     } 

enter image description here

回答

0

首先,使用文件>屬性菜單,以確定哪個IE安全區域測試網站被映射到。默認情況下,本地主機子域映射到Internet區域。如果你的本地主機,而不是,映射到Intranet區域,那麼將採用默認IE7的仿真模式(見工具>兼容性視圖設置>「在兼容性視圖中顯示Intranet站點」),不支持/渲染HTML5媒體元素和也將只運行32位BHO的,工具欄,或ActiveX控件(粗斜面運行64位代碼的32位CPU的)。

從IE轉到工具> Internet選項>安全選項卡,拳點擊「所有區域重置爲默認值」按鈕,重置您的開發計算機的瀏覽器安全設置回自己的工廠或公司GPO的默認值。

然後選擇...

Intranet區域>高級按鈕,從列表中刪除本地主機或127.0.0.1。保存您的更改。

回到IE瀏覽器,並刷新您的測試網站的頁面。使用IE中的文件>屬性菜單再次確認它現在映射到INTERNET安全區域。使用IE dev的工具的仿真標籤,確認它現在假定邊緣仿真模式(IE11)等能夠支撐HTML5媒體元素。

但是,您的屏幕截圖表明您的BHO甚至沒有加載到IE 32位選項卡進程中......您需要同時部署可在32位處理器和64位進程/選項卡上工作的32位和64位版本的BHO ....默認情況下,64位處理器上的IE只會加載64位BHO的標籤頁,這些標籤頁會加載映射到Internet(或Restricted)區域的網站。

您的BHO(在沒有用戶操作的情況下自動注入網頁中的內容)很可能會在野外部署時被標記爲惡意軟件...請參閱以下有關IE Addon開發「最佳實踐」的鏈接。

http://www.enhanceie.com/ie/dev.asp

https://msdn.microsoft.com/en-us/library/gg130949(v=vs.85).aspx