我有一个webBrowser1和一个wmpThing,它实际上是一个设置在我的WindowsForm中的Windows Media Player。我有一个HTMLDocument加载到webBrowser1与几个标签。这些标签中的每一个都指向.mp4视频。当我点击链接时,我试图让Windows Media Player播放视频,而不允许webBrowser1更改。这可能吗?
我尝试了以下操作,但它不允许我的浏览器导航到原始视频页面而不会在wmpThing.launchURL(url)上抛出异常;线
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
string url = e.Url.ToString();
try
{
textBox1.Text = "Launching:" + "\r\n" + e.ToString();
wmpThing.launchURL(url);
e.Cancel = true;
}
catch (Exception ex)
{
textBox2.Text = "oops: " + ex;
}
}
抓住结果:
oops: System.Runtime.InteropServices.COMException (0xC00D1329): Exception from HRESULT: 0xC00D1329
at WMPLib.IWMPPlayer4.launchURL(String bstrURL)
at AxWMPLib.AxWindowsMediaPlayer.launchURL(String bstrURL)
at FTVStreamer.Form1.webBrowser1_Navigating(Object sender, WebBrowserNavigatingEventArgs e) in C:\Users\Administrator\AppData\Local\Temporary Projects\FTVStreamer\Form1.cs:line 96