Javascript Event - statusCallback

7 replies [Last post]
sbraheem
sbraheem's picture
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 03/04/2010
Posts: 5

Hello everyone,

I am trying to integrate the Web Player in my application with javascript. I am able to register for the statusCallback event but have not been able to get the INIT_DONE event. Also, I often get an event id of 20.

So my question:
Is there anything I still need to do to get the INIT_DONE event?
What does the event id 20 stand for?

Thanks in advance.

sikiru

sbraheem
sbraheem's picture
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 03/04/2010
Posts: 5
It worked! How about plugin detection in IE

Hi,

Thanks for the response. I was using version 2.0.0, but it worked fine after upgrading to 2.0.1

I am working on integrating the Web Player in the BST Player project. The project provides an API to interact with media player plugins in GWT applications (and recently via javascript too). You can check it up @ [url=http://oss.bramosystems.com/bst-player]

Instead of waiting for the INIT_DONE event, I used the onload method though I feel the INIT_DONE event is a better way if available.

Now another question: How can detect the plugin via javascript in IE. I have been googling for hours with no success?

Thanks in advance.

peskypescado
peskypescado's picture
User offline. Last seen 7 weeks 6 days ago. Offline
Joined: 04/30/2009
Posts: 125
That is pretty awesome that

That is pretty awesome that you are integrating DWP into BST Player. Looks like a very interesting project. I'll have to check it out some more.

INIT_DONE is definitely the "right" way to do it, but unfortunately it wasn't being called properly before 2.0.1, but it should work for any version from 2.0.1 and later.

As for IE, what exactly do you mean by detecting it? Are you trying to detect if it is loaded, available, etc?

sbraheem
sbraheem's picture
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 03/04/2010
Posts: 5
By plugin detection, I mean

By plugin detection, I mean checking if the plugin is installed and enabled on a browser. For example in non-IE browsers, I can use the navigator.mimeTypes['video/divx'] to see if DWP is installed and enabled and also check for the version. IE uses activex objects instead!

I can see the DivXBrowserPlugin activex object loaded in IE but can't figure out how to create/access the object. E.g. with flash I can do new ActiveXObject("ShockwaveFlash.ShockwaveFlash") to check for the plugin and its version.

Thanks in advance.

peskypescado
peskypescado's picture
User offline. Last seen 7 weeks 6 days ago. Offline
Joined: 04/30/2009
Posts: 125
This is some code I've used
Here is some code I've used for DWP detection. It works in IE, FF, Chrome, Safari, and only has to actually load the plugin to determine the version for IE.
function DWPCheck()
{
    dwpPlugin = new Object;
    dwpPlugin.version = "None";
    dwpPlugin.installed = false;

    var userAgent = navigator.userAgent;
    if (userAgent.search(/msie/i) != -1) // If IE
    {
        var dwp = null;
        try
        {
            dwp = new ActiveXObject('npdivx.DivXBrowserPlugin.1');
        } catch (e) { }

        if (dwp)
        {
            dwpPlugin.version = dwp.GetVersion();
            dwpPlugin.installed = true;
        }

    }
    else // Else every other browser
    {
        if (navigator.plugins != null && navigator.plugins.length > 0)
        {
            plugins = navigator.plugins;
            for (var i = 0; i < plugins.length; i++)
            {
                // Search for DivX Web Player and version number
                var re = /DivX(?: | Plus )Web Player[a-z ]*([0-9.]*)/;
                var results = re.exec(plugins[i].description);

                if (results)
                {
                    dwpPlugin.installed = true;
                    dwpPlugin.version = results[1];

                    // End search
                    i = plugins.length;
                }
            }
        }
    }

    // Perform different actions based on DWP x.y.z version
    switch (dwpPlugin.version.substr(0, 5))
    {
        case "None":
            return false;
            break;
        default:
            if (dwpPlugin.version.substr(0, 1) == "1") // If DWP 1.x
            {
                dwpPlugin.formats = new Array('AVI');
            }
            else // 2.x or higher
            {
                dwpPlugin.formats = new Array('MKV', 'AVI');
            }
            return true;
    }
}
peskypescado
peskypescado's picture
User offline. Last seen 7 weeks 6 days ago. Offline
Joined: 04/30/2009
Posts: 125
Try this for IE:

Try this for IE: ActiveXObject('npdivx.DivXBrowserPlugin.1');

Example:
var dwp = null;
try
{
dwp = new ActiveXObject('npdivx.DivXBrowserPlugin.1');
}
catch (e)
{
}

if (dwp)
{
dwpversion = dwp.GetVersion();
dwpInstalled = true;
}

sbraheem
sbraheem's picture
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 03/04/2010
Posts: 5
Thanks, that is what I've

Thanks, that is what I've been looking for!

Regards.

peskypescado
peskypescado's picture
User offline. Last seen 7 weeks 6 days ago. Offline
Joined: 04/30/2009
Posts: 125
Which version of Web Player

Which version of Web Player are you testing against? That is one of the things that we worked to correct in the 2.0.1 release on Labs.

Are you trying to trigger something for once DWP has loaded? I know it doesn't do exactly the same thing, but I usually add a function that gets run onload for the body tag. That will run once all of the page elements (like DWP) have loaded. The downside is that if you have some page element (e.g. Flash widget, iframe ad unit, etc) that gets pulled in from a remote server it could delay the onLoad call by a few seconds.

< body onload="onLoadRun()" >

As for the event 20 calls, ignore them. It shouldn't be triggered but DWP 2.0.0 has a bug where it sends it. That has also been fixed in the 2.0.1.

2.0.1 Download Links:
Win: http://labs.divx.com/files/DivXWebPlayerInstaller_2.0.1.940.exe
Mac: http://labs.divx.com/files/DivXWebPlayerInstaller_2.0.1.940.zip

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.