Theming the Drupal flashvideo module with swfobject.

[img_assist|nid=11|title=|desc=|link=none|align=right|width=87|height=100]The FlashVideo module is great, but you may want to embed the video with swfobject, so here's one way to do it.

Of course for this to work you're going to need to include swfobject.js in your template. How you do that depends on your theme and is a little beyond the scope of this article.

Once you have that setup, you just need to open up template.php and add ths theme override function.

<?php/** * Override flashvideo embed code */function phptemplate_flashvideo_play_flash($video) {  // Initialize index variable used for multiple players if it doesn't exist  if (!$GLOBALS['flashvideo_embed_index']) { $GLOBALS['flashvideo_embed_index']=0; }  // increment index  $GLOBALS['flashvideo_embed_index']++;    // Get the FlashVars for this video.  $flashvars = flashvideo_get_flashvars($video);  // Creates an absolute path for the player.    $loader_path = check_url(file_create_url(flashvideo_variable_get($video['nodetype'], 'player', 'Player.swf')));  $image = str_replace('.flv', '.jpg', $video['file']);    $output .=<<<EOF  <div id="video-player-{$GLOBALS['flashvideo_embed_index']}"></div>  <script type="text/javascript">  var so = new SWFObject('/misc/mediaplayer.swf','mpl','450','357','8');  so.addParam('allowscriptaccess','always');  so.addParam('allowfullscreen','true');  so.addVariable('displayheight','357');  so.addVariable('displaywidth','450');  so.addVariable('file','{$video['file']}');  so.addVariable('image', '{$image}');  so.addVariable('backcolor','0x000000');  so.addVariable('frontcolor','0xEEEEEE');  so.addVariable('lightcolor','0xFFFFCC');  so.addVariable('screencolor','0x000000');  so.addVariable('searchbar','false');  so.addVariable('showdigits', 'true');  so.write('video-player-{$GLOBALS['flashvideo_embed_index']}');  </script>EOF;     return $output;}?>

This code is using the JW FLV Player, so your swf parameters may differ if you are using something else.