Suggested change to flashvideo_get_flashvars?

pobster - March 14, 2009 - 18:25
Project:FlashVideo
Version:6.x-1.5-rc3
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:needs review
Description

Patch against DRUPAL-6--1-5-BETA2:

Just a suggestion to take advantage of drupal_alter for Drupal 6.x onwards - change would allow a hook like this;

function mymodule_flashvar_extra_alter($flashvars) {
  // Set up the markup and actual data arrays.
  $markup = array('@abouttext', '@aboutlink');
  $actual = array('I_Have_A_License', 'http://developer.longtailvideo.com/trac/wiki/FlashVars#External');
  return str_replace($markup, $actual, $flashvars);
}

It's hardly gold but useful I guess?

Thanks,

Pobster

AttachmentSize
flashvideo-module.patch894 bytes

#1

pobster - March 14, 2009 - 21:03

Just in case the purpose of this is lost on anyone I'll just explain why its useful...

You can change the flashvars for each node type on the settings page under "Flash Player Settings" to use custom flashvars:

"Custom FlashVars (do not change for default functionality):"

Currently there are two 'tokens' you can use which are @video and @thumbnail. Utilizing the above patch allows you to define your own tokens, this is useful-ish as when the FlashVideo module is updated to a new release (assuming the patch is committed) your tokens will still be altered as your code is in a separate module and therefore unaffected by upgrading to the new release.

...I guess if required you could link to the same hook_flashvar_extra_alter in the flashvideo.admin.inc file to return some extra text for the description parameter? Something like...

function mymodule_flashvar_extra_alter($flashvars, $description = FALSE) {
  if ($description) {
    return t('<b>@abouttext</b> - <em>String</em> - Placeholder for altering the about text when you right click on the player.');
  }
  // Set up the markup and actual data arrays.
  $markup = array('@abouttext', '@aboutlink');
  $actual = array('I_Have_A_License', 'http://developer.longtailvideo.com/trac/wiki/FlashVars#External');
  return str_replace($markup, $actual, $flashvars);
}

Then do something like a module_invoke_all mixed in with an implode in the setting for the custom vars parameter...

sprintf("<li>%s</li>", implode("</li><li>", module_invoke_all('flashvar_extra_alter', NULL, TRUE)));

Or not bother with building the li tags manually and return an array which you'd pass to theme('item_list') to build your list (easier?)

Just a thought? Love the module btw!

Pobster

#2

pobster - March 14, 2009 - 21:13

On second thought, maybe it's better to pass $video into the alter hook? I guess it'll be more useful if you wanted to skin the player for each node type?

(Just for information: I haven't included the description thing I mentioned above in this patch, it's just a simple version).

Pobster

AttachmentSize
flashvideo-module.patch 902 bytes

#3

Alex72RM - August 12, 2009 - 14:58
Version:6.x-1.5-beta2» 6.x-1.5-rc3

I find that this is a very useful improvement for the module.

By the way, I need to get video node title and author.

I tried with $node->title and $node->name (into $actual array, with placeholders into $markup array), with no success.
Sorry, I don't have a good knowledge of Drupal variables.

Can someone help me?

Thanks!

#4

Alex72RM - August 21, 2009 - 10:37

Hi again,

I solved by myself.

The solution is based on rewriting contemplate entry for specific content:

$params['flashvars']['title'] = check_plain($node->title);
$params['flashvars']['author'] = $node->name;
$params['flashvars']['dateUpload'] = date('j/n/Y',$node->created);

print flashvideo_get_video($node,$params);

 
 

Drupal is a registered trademark of Dries Buytaert.