简体   繁体   中英

WPF WebBrowser Control will not load video in a locally hosted HTML page

I have a WPF application written in C#. This application has two WPF WebBrowser controls next to each other. Each one navigates to a different locally-hosted HTML file. Each HTML file has a video element which points to an .mp4 video file stored in the same directory.

My problem is that the video content does not render in the WebBrowser controls. If I use the exact same URL and put it into Internet Explorer 11 on the same PC, the video content runs perfectly fine. I know the actual navigations of the WebBrowser controls are working because the page half-renders. I can see the background color show correctly but that is it. If I right-click inside one of the controls and view the source, I can see the correct HTML there.

Attempting to apply the recommendation in an answer to this question to Internet Explorer 11, I tried having the WebBrowser controls in my executable run like IE11 using the information in this link with no success.

I'm not sure if this is relevant, but I already have "Allow active content to run in files on My Computer" checked in Internet Options on Internet Explorer.

Here is the HTML markup for the video:

<div id="video_holder">
<video id="video" width="1200" height="900" autoplay>
    <source src=".\FANCY.mp4" type="video/mp4">
</video>
</div>

And here is the code that calls the Navigate() method of the WebBrowser controls (the constructor for this Form receives the urls from another class - I'm pretty sure the problem isn't here, though, as I can see that the actual navigation seems to be working and the HTML starts to render):

public partial class TwoPaneWindow : Window
{
    private string leftUrl;
    private string rightUrl;
    public TwoPaneWindow(string left, string right)
    {
        leftUrl = left;
        rightUrl = right;
    }
    public void StartWindow()
    {
        InitializeComponent();
        this.Show();
        LeftBrowser.Navigate(leftUrl);
        RightBrowser.Navigate(rightUrl);
    }
}

Can anyone tell what is going on? I am hosting this on IIS installed on Windows 8.1. Thank you in advance for any help you can offer.

Finally figured this out. Even though I said I tried the answer to this question , I was actually using the FEATURE_BROWSER_EMULATION key incorrectly. I attempted to add FEATURE_BROWSER_EMULATION to HKEY_LOCAL_MACHINE \\SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl, when in fact it needs to be modified at HKEY_CURRENT_USER \\Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION. Once I created a new DWORD entry for my application (sharing its name) with a value of 0x2AF8, the WebBrowser controls immediately started working correctly. A newbie mistake I'm sure, but hopefully this helps someone else in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM