diff --git a/swftools.module b/swftools.module
index 7945063..7cd0332 100644
--- a/swftools.module
+++ b/swftools.module
@@ -497,8 +497,8 @@ function swf($file, $options = array()) {
   // all existing values by reference to allow optional override at the player.module level.
   if (module_hook($resolved_methods->player['module'], 'swftools_flashvars')) {
 
-    // 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);
     
     // Merge player flashvars with existing flashvars
     if (is_array($player_flashvars)) {
@@ -1927,3 +1927,32 @@ function theme_swftools_formatter_playlist($element) {
   return swf($files);
   
 }
+
+/**
+ * Invokes hook_swftools_flashvars() in the relevant player module.
+ *
+ * We cannot use module_invoke() for this, because the arguments need to be passed by reference.
+ *
+ * @param $action
+ *   String defining the action that is to be performed, eg SWFTOOLS_FLV_DISPLAY
+ * @param &$methods
+ *   Object containing two keys - player and method. Each consists of an array
+ *   that defines the details of the resolved player and embedding method that
+ *   is being used for this file.
+ * @param &$vars
+ *   Object containing three keys - othervars, flashvars and params. These are
+ *   arrays containing key/value pairs that contain all the data assigned to this
+ *   file so far. Refer to swf() for more details about the $vars array.
+ * @return
+ *   Return an array of flashvars needed to allow the player to work.
+ */
+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
+  return($function($action, $methods, $vars));
+
+}
+
