Passing custom-parameters from link, through shadowbox, to the flash player

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Passing custom-parameters from link, through shadowbox, to the flash player

jmusick
Hi,

I've been trying unsuccessfully to figure out how to code some custom parameters that can be "fed" through the shadowbox call and into a custom flash player.

For example - say I want to pass a path (to an xml location) to my flash player. Normally I could code the HTML link with a parameter ?xmlPath=someEndpoint.xml

but with Shadowbox I have tried a few things and not gotten it to work. Here's what I've tried:
1. Simply appending ?xmlPath=someEndpoint&xmlID=someNumber  to the href="" attribute
    This did *not* work, and in truth I didn't expect it to, but it was worth trying. Putting debugging in the javascript indicated that among other reasons, the & isn't encoded, and it seems like shadowbox is only expecting a path directly to a flv, not anything else there
2. adding custom options into the javascript, and then passing in values in the rel="" attribute
    This didn't work - which again isn't too surprising because it looks (?) like shadowbox is constructing an xml heirarchy and passing to somewhere (not sure where) that then uses SWFObject and adds in the params as necessary.

What would be great is to understand how to add a custom attribute so that the end result is that I'm ultimately getting an "addParam()" call with my attribute name & value put in there.

So when shadowbox makes the ultimate flash object initiation it executes
addParam(xmlPath,someEndpoint)

For whatever custom variables there are.

Thoughts/recommendations/suggestions?  I'll keep looking for an easy (or do-able) way to do this, but pointers would be much appreciated!

Thank you,
-James
Reply | Threaded
Open this post in threaded view
|

Re: Passing custom-parameters from link, through shadowbox, to the flash player

jmusick
Ok - I've made some progress that I'll post...

My idea is that many "custom built" flash players require additional parameters, other than the default 'flashvars' and/or params that are currently supported in Shadowbox.  The most modular way of handling this seemed to me to be this:

1. Have an additional option customPlayerParamArray: []
    This option would be an array of objects of type customPlayerParams
2. Create the prototype object customPlayerParams
    function customPlayerParams (sName, aValues){
        this.paramName = sName;
        // in some, unusual, cases URL parameters have more than one value.
        this.paramValues = aValues;
        this.getName = function(){return this.paramName;}
        this.getValues = function(){return this.paramValues;}
    };
3. Add the custom params to the var flashvars
    by looping through the array customPlayerParamArray and using
    options.customPlayerParamArray[i].getName();
    options.customPlayerParamArray[i].getValues();
4. Set the options in the HTML
    var oTEST  = new customPlayerParams('test','foobar');
    var options = {customPlayerParamArray:[oVideoIDs, oXMLPath]};
    Shadowbox.init(options);

The above works fine - the catch is when you want to use a "per link" option that is different than the one originally set.
1. The current rel="options{}" only lets you set basic values (strings, ints, etc) - not javascript objects
2. I then tried an href="javascript:Shadowbox.open('linkpath', options )"
    This passed it into shadowbox.js properly, but the open() method calls this.revertOptions(); - so you lose everything you pass in (without continuing modification of the js).

So it works fine for the 'per page' creation of custom params, but not the per-link.

I think my only option at this point is to revert to a non OO-based approach, which is unfortunately more limiting.

-J