KristijanSharp
KristijanSharp

Reputation: 133

Check if .NET webbrowser control can play flash

how can i check from code if webbrowser control can play flash or it showing broken image, after flash page is loaded?

Idea is that if user can't play flash, application should open Internet explorer with adobe flash player website, so user can install flash in IE, and enable flash content.

Thanks

Upvotes: 0

Views: 1086

Answers (2)

vcsjones
vcsjones

Reputation: 141638

Since Flash in IE is an Active-X control, you can use C# from the application itself to see if you can instantiate a a COM object with Flash's Class ID:

private bool IsFlashInstalled()
{
    object instance = null;
    try
    {
        var type = Type.GetTypeFromCLSID(new Guid("d27cdb6e-ae6d-11cf-96b8-444553540000"));
        instance = Activator.CreateInstance(type);
        return true;
    }
    catch (Exception)
    {
        return false;
    }
    finally
    {
        if (instance != null)
        {
            Marshal.FinalReleaseComObject(instance);
        }
    }
}

You'll probably want to cache the result as much as possible.

Upvotes: 1

Richard
Richard

Reputation: 8280

For all of your flash related needs, I would recommend using the SWFObject JavaScript library.

Tutorial: "Detecting Flash Player versions and embedding SWF files with SWFObject 2"

Upvotes: 0

Related Questions