Just try to get it working in a Drupal 5.1 site.
I have this in my page.tpl.php:

   $url = 'http://sandbox/public/themes/themename/images/flashmovie.swf'; //path to flash file
   $params = array(
   	'width' => 849,
   	'height' => 132
   	);
   /*$vars =  array(''
     'file' => base_path() . path_to_theme() .'/files/song.mp3',
     'image' =>  base_path() . path_to_theme() './files/image.jpg', 
    );*/
   print theme("swfobject_api", $url, $params, $vars);

and I get this output:

<div id='flashcontent-flashmovie'>Sorry, you need to install flash to see this content.</div>
<script>var so = new SWFObject('http://sandbox/public/themes/themename/images/flashmovie.swf', 'movie', '849','132','flashmovie'); 
 $(document).ready(function () { so.write("flashcontent-flashmovie");}); </script>

Comments

hanskuiters’s picture

And an error in de concole:
Error: SWFObject is not defined

hanskuiters’s picture

If I call the swfobject.js directly in the page.tpl.php, as stated in http://drupal.org/node/126594, I get the error in console: $ is not defined

arthurf’s picture

Status: Active » Postponed (maintainer needs more info)

Please try the DRUPAL-1--1-2 version and check to see that the swfobject.js file is accessible

Devis’s picture

I had the same problem, solved adding
drupal_add_js(drupal_get_path('module', 'swfobject_api') .'/swfobject.js');
in my template.php.

In my opinion you can't call drupal_add_js in the page.tpl.php, this should be called before $scripts gets generated.

arthurf’s picture

I'm curious about the need for doing this- and am wondering if the issue going on is actually caching. If caching is turned on, it could be the case that Drupal would not be making the call to render the swf again for users being served cache content. This would prevent the the drupal_add_js() call from being executed. So- is your caching on?

Devis’s picture

No I don't use caching. In my opinion calling print theme("swfobject_api", $url, $params, $vars) inside page.tpl.php is too late to put swfobject.js in the html header; there should be something that calls that drupal_add_js before the template file is loaded.

arthurf’s picture

Status: Postponed (maintainer needs more info) » Fixed

There is a fix for this in the latest release. Should be resolved.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

brunodbo’s picture

Status: Closed (fixed) » Active

I'm still having this problem. Tried solving it with Devis' solution (#4), but it didn't work.

This is what's in my node.tpl.php:

  <?php

   $url = "http://localhost/themes/garland/mediaplayer.swf"; //path to flash file
   $params = array('width' => 640, 'height' => 480 );
   $vars =  array(
     'file' => 'http://localhost/files/midroll.flv'
    );
   print theme("swfobject_api", $url, $params, $vars);

  ?>

This is what's outputted:

<div id="flashcontent_mediaplayer_1" >Sorry, you need to install flash to see this content.</div>
<script type="text/javascript" src="/sites/all/modules/swfobject_api/swfobject.js"></script><script type="text/javascript">var so1 = new SWFObject('http://localhost/themes/garland/mediaplayer.swf', 'swf_mediaplayer_1', '640', '480', '5', '#FFFFFF');
 so1.addParam('type', 'movie');
 so1.addVariable('file', "http://localhost/files/midroll.flv");
 $(document).ready(function () { so1.write("flashcontent_mediaplayer_1");}); </script>
arthurf’s picture

Do you have any javascript warnings on that page?

brunodbo’s picture

Status: Active » Closed (fixed)

Seems like I was mixing up module & swfobject versions. Sorry 'bout the noise.

arthurf’s picture

No worries, I just wanted to make sure everything was ok.

ryosaeba’s picture

Dear friends

I've the same problem here

http://www.walterfantauzzi.com/node/60

How Can I resolve it?