Search code examples
javascriptwindowsocxwmp

How to get the error code of WMP plugin in IE when it fails to play some resource?


Recently I'm trying to make a web page for WMP troubeshooting.And what I want to do is, if the vistors cannot play the resource on my page because of some problems such as missing WMP codec,failing to pass DRM...etc, then I'll show them some information about how to fix it.I've googled an example and the problem is the property ErrorCode of the WMP object wmpocx always comes up as undefined while it do exist there.So how can I get the WMP error code in JSCript?

Regards


Solution

  • Find the solution by reading the source code of the Security component upgrade page on Microsoft's website.

    Main code:

    var error = wmpocx.error;
    var errorItem;
    var index;    //index into the error queue.
    var message;
    
    //The error is an error object that can have multiple errors in a queue
    //error.errorCount is the count of errors in the error queue
    for(index=0; index<error.errorCount; index++)
    {
        errorItem = wmpocx.error.item(index);
        //you can get information on the error with the following properties
        //errorItem.errorCode
        ecode = errorItem.errorCode;
        message = errorItem.errorDescription;
    }