Intercepting Clicks to WebBrowser

0

I have a webBrowser1 and a wmpThing that is actually a Windows Media Player set into my WindowsForm. I have a HTMLDocument loaded into the webBrowser1 with several tags. Each one of these tags points to a .mp4 video. I am trying to get the Windows Media Player to play the videos when I click the links, and not allow the webBrowser1 to change. Is this possible?

I tried the following but it won't allow my browser to navigate to the original video page without throwing an exception on the wmpThing.launchURL(url); line

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;
        }

    }

Catch Results:

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
c#
winforms
url
html-agility-pack
windows-media-player
asked on Stack Overflow Jun 17, 2011 by Danejir • edited Jun 17, 2011 by Danejir

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0