If I use standalone Wijering player, I can set video preview image by flashvar "image". How can I do the same thing via swftools?

Cheers.

Comments

ariana’s picture

I'd love to know this too.. right now I get a blank screen and have to right click and hit play to get the video to start!

bsuttis’s picture

Probably not the most elegant solution, but after looking through the wijering.module code, I found that the background image looked like it was only applying to mp3s, so I just duplicated lines 285-293 and changed the file extension to flv

/* added lines for video bg */
    if (!isset($details['background']) && strtolower(substr($details['fileurl'], -3, 3)) == 'flv') {
      if (isset($vars->flashvars['image'])) {
        $details['background'] = swftools_get_media_url(swftools_get_media_path() .'/'. $vars->flashvars['image']);
      }
      else {
        $details['background'] = SWFTOOLS_DEFAULT_BG;
      }
    }

Dropping my cached playlists and refreshing displayed the background image. I suppose a better way of going about this is providing a UI form option.

carldnelson’s picture

I tried this and it did not work. Did you add the duplicated code just below the code for the mp3's or somewhere else in the file? It seems really weird that there is no simple way to have a background image for the flv video file. The big black box just seems so ugly.

bsuttis’s picture

Right below, indeed.

Make sure you clear your cached playlists, that could be the issue.

dagomar’s picture

If you use flash node, it is pretty simple. When you create the flashnode, put the flashvar in "advanced flash node options":

image=path/to/image

(note that it will automaticaly look in the folder "files", so if your image is in 'files/images/image.jpg' the flashvar is"
image=images/image.jpg)

WorldFallz’s picture

+1 to this--- I can't get this working either and I've spent hours pouring over the posts and trying different things. Anyone spare the exact steps necessary to get this working-- it would be greatly appreciated.

Thanks.....

susata’s picture

Just wondering if anyone has figured out a solution to this problem. Last night, before I came across this thread, I posted a new support request for what could be the very same problem: http://drupal.org/node/216946 .

s.

yan’s picture

Version: 5.x-1.x-dev » 5.x-2.1

Same question here. I use

print swf($video_file['value'], array('width' => '350', 'height' => '280'));

in my template file to show the video. The values for width and height work fine, but if I add an image path as suggested for mp3-files

print swf($video_file['value'], array('width' => '350', 'height' => '280', 'image' => 'image/path/to/file.jpg'));

it is ignored. My html source code just shows the rest:

<param name="FlashVars"  value="width=350&height=280&file=http://example.com/files/file.flv" />

Is it still not possible to set the preview image with SWF Tools?

Stuart Greenfield’s picture

Which Wijering player are you using?

yan’s picture

Version: 5.x-2.1 » 5.x-2.2

I'm not sure which version of the Wijering player it was, but I just installed the 4.1 version and updated the SWF Tools module to 2.2 and the problem is the same.

yan’s picture

Sorry for bugging, but isn't this a quite common use for SWF Tools? The issue is more than a year old and there has really been no solution for this? I'm just wondering because other flashvars do work, why then doesn't the preview image?

Stuart Greenfield’s picture

It might be common, but sometimes it takes time for the maintainers to answer all the queries :-) I only adopted SWF Tools recently, and the first priority had to be to get a working SWF Tools 6 out (which is done), and then to start working the issue queue. There are a lot of issues in the queue, and several are old. They are now in the process of being closed, and a lot were closed as part of the update to D6, but there are still more to do (this being one of them).

So, they will get addressed, but can't make any promises about when!

Stuart Greenfield’s picture

With the swf filter it is very easy...

<swf file="video.flv" image="image.jpg">

With SWF Tools 5 you need to pass NULL if you are not providing any other parameters

print swf('video.flv', NULL, array('image' => 'image.jpg'));

With SWF Tools 6 you need to use the new array format, so you can just pass the relevant flashvar

print swf('video.flv', array('flashvars' => array('image' => 'image.jpg')));

Note - testing this syntax revealed an issue with SWF Tools 6 that was stopping flv files playing, so you need SWF Tools 6.x-1.3 or later.

--edit
Note - error in <6.x-1.3 only applies if you set the caching for files to "always" in the SWF Tools file handing options - if you don't set this then you won't be affected by this bug.

yan’s picture

Status: Active » Fixed

That works, thanks!

Know I'm wondering if I could use imagecache to adjust the image to the video size ...

dabro’s picture

Thanks for the above bit of code, it helped me a lot. Here's how I made my preview image show up on the player. I created a filefield to upload the video file. The filefield is labeled field_media. That was working right off but no preview image with this code.

<?php print swf($node->field_media[0]['filepath'])?>

I created an image upload field labeled "field_media_image" and used the following code (thanks to Stuart). The "podcast_files" element of the array is the subdirectory of my files directory. It works, you can upload a preview image with the movie upload and it appears in the player.

<?php print swf($node->field_media[0]['filepath'], array('flashvars' => array('image' => 'podcast_files/' . ($node->field_media_image[0]['filename']))))?>

BTW, this code goes in the node.tpl file for your movie nodes. I hope this can help somebody, YMMV, Dave

armourymedia’s picture

Thanks, dabro and Stuart, for this very helpful bit of code. I've got a requirement to display video in-line with body field text so I'm using the input filter. I'm able to specify height and width, but the "image" variable doesn't work. Can anyone help with this? Is there documentation somewhere that outlines available variables for the input filter and the syntax to use? The handbook page only refers to adding filenames and it was only by chance that I found out that other variables are accepted through the input filter.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

amariotti’s picture

Version: 5.x-2.2 » 6.x-2.5
Category: support » bug

I hate to open this up again, but this is still an issue. Why would the module bypass this variable? Having a standard image on the video for the user is very important in lots of cases. Anyone been able to get a workaround for Drupal 6?

jrust’s picture

Just a note that this is how to insert a background image in the D6 version using the input filter (note that bg-image.jpg should be in the same folder as video.flv):
[swf file="video.flv" flashvars="image=bg-image.jpg"]

4v4l0n42’s picture

Awesome, this worked perfectly! :D

webnation’s picture

Thanks Dabro (and everyone) for this. It works brilliantly. But as I don't understand php, I don't know what code to use for an optional field.

I created an optional video field "field_video" and an optional video image field "field_video_image". I created a directory for the images "video_files" and used the following code in my node.tpl file for a certain content type:

print swf($node->field_video[0]['filepath'], array('flashvars' => array('image' => 'video_files/' . ($node->field_video_image[0]['filename']))))

It works perfectly adding the preview image to the front of the video but if I don't upload a video to the page it creates the error message: "No player is configured to play a series mixed media files. Check the SWF Tools file handling settings on the configuration page." and adds the following in the body of the page "You are missing some Flash content that should appear here! Perhaps your browser cannot display it, or maybe it did not initialize correctly."

How can I make it work only when I upload a video and not when I don't use those fields? I'd really appreciate any help on this. Thanks, Mike.

webnation’s picture

By trial and error I've got it work with:

if ($node->field_video[0]['filepath']):
print swf($node->field_video[0]['filepath'], array('flashvars' => array('image' => 'video_files/' . ($node->field_video_image[0]['filename']))))
endif;

No idea how correct it is but it works.....

johnhanley’s picture

Thanks to dabro for this post. Works like a charm and saved me some time.