Monday, March 8, 2010

warning: Parameter 2 to flowplayer3 swftools flashvars()

While the php version has been upgraded, the swf tools for playing the flv video has been so difficult to make a video to play. 

The problem faced by the people regarding the swf tool has been discussed over here . Even i have gone through and tried to changed the solution but could not do it. I was having this error  warning: Parameter 2 to flowplayer3_swftools_flashvars() expected to be a reference, value given in C:\wamp\www\drupal-6.14\includes\ on line 450.

Finally i got to go back to have some dirty code:

Rather than remove the pass by reference and break the ability of FlowPlayer3 to over-ride the embedding, which is a necessary capability to support some advanced FP3 things that are coming, I've written an alternative function to call the hook, in a similar vein to user_module_invoke. It's a little simpler because we know the module we're calling.
Upshot is that passing by reference now works without any complaints from PHP. This code is on branch DRUPAL-6--3 as I anticipate this is where the next release will come from. To implement the fix manually to an existing SWF Tools installation change line 500 in swftools.module from:
// Get player flashvars$player_flashvars module_invoke($resolved_methods->player['module'], 'swftools_flashvars'$action$resolved_methods$vars);?>
// Get player flashvars - use a custom invoke to allow pass by reference$player_flashvars swftools_flashvars_invoke($action$resolved_methods$vars);?>
and add this new function at the end of the swftools.module:

function swftools_flashvars_invoke($action, &$methods, &$vars) {

// Build the name of the function we are going to call
$function $methods->player['module'] . '_swftools_flashvars';

// Call the function and return the resulting flashvars to the caller

Note to self - this issue isn't fully resolved yet - there are other calls to swftools hooks (e.g. hook_swftools_playlist) that also rely on module_invoke by are written to receive parameters by reference.