Hello,

drupal 6.10

I installed last version of swfobject drupal module (6.x-1.0-beta1), downloaded the swfobject library (v2.1) like explain in the readme file, put swfobject.js and expressInstall.swf into swfobject_api module folder, and finally add this code in "page" contemplate body :

<?php

$url = "http://auto.titouille-local.ch/flex/drupalTest.swf"; 
$params = array('width' => 400, 'height' => 300 );
$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); 

?>

The source page include in the header the swfobject script :

<script type="text/javascript" src="/modules/swfobject_api/swfobject.js?y"></script>

The swfobject-1 div is like this :

  <div class="content">
    <div id="swfobject-1" class=" swfobject">Sorry, you need to install flash to see this content.</div>
  </div>

and at the bottom of the page, I have the following code :

<script type="text/javascript" src="/modules/swfobject_api/swfobject_api.js?y"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "swfobject_api": { "files": { "swfobject-1": { "url": "http://auto.titouille-local.ch/flex/drupalTest.swf", "params": { "type": "movie", "bgcolor": "#FFFFFF" }, "flashVars": { "file": "/themes/acquia_marina/files/song.mp3", "image": "/themes/acquia_marina/files/image.jpg" }, "attributes": [  ], "height": 300, "width": 400, "express_redirect": "modules/swfobject_api/expressinstall.swf", "version": "6", "bgcolor": null } } } });
//--><!]]>
</script>

I tested http://auto.titouille-local.ch/modules/swfobject_api/swfobject.js and swfobject js file is displayed so I think it's ok with the swfobject library.

I have tried with relative path ./flex/drupalTest.swf, /flex/drupalTest.swf, and full http path like in the code I wrote under, but no correct result... I don't understand what is wrong, because the js is included at the top of the page.

Any suggestion would be appreciated.

CommentFileSizeAuthor
#6 407142.patch798 bytesGeorge2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arthurf’s picture

would you mind giving me a URL that I could look at where the code isn't working?

titouille’s picture

Sorry but this is on a local installation. I'll see if I can put it on my local server and give you an url ;-)

arthurf’s picture

If you have firebug installed, you can see if there are any JS errors that are happening that might prevent the loading of the SWF file. You might also want to try using a full url to your images and mp3- eg: url(path_to_theme() .'/files/image.jpg', array('absolute' => true));

Let me know if that helps.

titouille’s picture

Re,

I tried to install same build on my local server and it work, all is ok. I don't know why it's broken on my local computer, but it seems ok on the server. Sorry for the disturbance :-|

arthurf’s picture

Status: Active » Closed (fixed)

I'm guessing it's a URL/domain issue- you might want to create a cross domain file, or making sure that your URLs are absolute

George2’s picture

Status: Closed (fixed) » Needs review
FileSize
798 bytes

i had exactly the same problem, and it came down to a templating issue.

i put $scripts right at the bottom of the template for performance reasons, like so:

...
...
...
    <?php print $closure; ?>
  </div>

	<?php print $scripts; ?>
  </body>
</html>

this threw up a js error that "Drupal is not defined", and "JQuery is not defined"... so, moving the scripts above the closure did the trick. however, i don't want to do that as closure can contain html and for optimisation purposes, i'd like to have $scripts at the bottom.

in the swfobject_api_ensure_swfobject function, is there a particular reason why the last two js calls are added to footer?

i'd like to be brash, and suggest that the drupal add js's are moved to the header. i've tested with $scripts at the top, and $scripts at the bottom, and this does the trick

thanks

arthurf’s picture

Status: Needs review » Postponed (maintainer needs more info)

As a general rule, I think $scrips needs to be displayed above $closure. In this case, You'd load settings and the controller function before the swfobject.js library is loaded, which I'd guess is the source of the problems. As far as I know, the common thinking at this point is to try to load as much of the JS in the footer as possible to decrease page load times. I'm fine to move things back to the header, but I have this functioning on a few sites where $scripts is displayed before $closure and it works fine for me. Can you give this a try? I'll try to duplicate your setup and see if that is the source of the errors.

George2’s picture

if i move $scripts before $closure, sure, it works fine. however, i don't think this is preferential, and so in the templates, i moved the $scripts after the $closure which causes problems for swfobj api.

the patch above fixes the problem.

arthurf’s picture

Why don't you think this is preferential? Can you point me to some documentation so I can understand better where you're coming from? I'm not understanding what would be in $closure that would make you want to have it above $scripts?

arthurf’s picture

Also, please see this article by Wim: http://wimleers.com/article/improving-drupals-page-loading-performance#a... as well as this: http://groups.drupal.org/node/8399#comment-25894

In both of these cases, they seem to be pretty clear that $scripts goes should before $closure. Again, I'm willing to be convinced otherwise, but at this point, I think the issue is how you've done the page structure- of course, that begs a question about how javascript is placed into the page template, but I'm not going there ;)

George2’s picture

bah humbug :p

LateNightDesigner’s picture

I'm having the same problem as titouille. I receive a "Sorry, you need to install flash to see this content." This is on a live site, not a local installation.

My paths are absolute, as shown below:

<?php
$url = "http://example.com/content/themes/fourseasons/site_banner.swf"; //path to flash file
$params = array('width' => 940, 'height' => 92 );
print theme("swfobject_api", $url, $params);?>
SeanBannister’s picture

I can confirm this problem and my $scrips is displayed above $closure

robotjox’s picture

confirming too

arthurf’s picture

What is the js that is being printed on your page?

BlindWolf8’s picture

Hello,
I am also having this issue when trying to post the PHP code in nodes or in a theme. However, I have no trouble when using it in a CCK Contemplate. I am using Drupal 5.16 and SWFObject API 5.x-2.0-beta3.

The JS gets called at the top of the page. I can confirm that code called using this module and a CCK Contemplate (referenced above) breaks when $scripts is called at the bottom of the page/template as other peopel in this thread were discussing.

Thanks for any info!

BlindWolf8’s picture

PS: I tried putting in code manually, and it works fine. I think it has something to do with Express Install not getting loaded right. Can anyone else confirm?

tiato’s picture

I was using SWFObject to stream a remote SWF (NOT FLV) video tutorials. It was working fine until I updated Embedded Media Field which I use to add a custom URL field to content types.

I received this same error about installing flash player after updating Embedded Media Field module.

I was using the following config after update:
-Drupal 6.14
-Embedded Media Field 6.x-1.15
-SWFObject API 6.x-1.0-beta1

I tried #12 by editing the nodes, also disabled JW Player from EMF and it does play videos again but the weird thing is the html source doesn't look much different

Before #12 is applied this is the outpout:

 <div class="emvideo emvideo-video emvideo-zzz_custom_url"><div id="swfobject-2" class=" swfobject">Sorry, you need to install flash to see this content.
</div>

After #12 is applied and the video is working (streaming again), the output is not much different:

</div>
<div id="swfobject-1" class=" swfobject">Sorry, you need to install flash to see this content.
</div>

I have verified that swfobject.js is being loaded though it is Aggregated and GZipped. I have also disables Java Aggregator and GZip to confirm that swfobject was loading.

Even the source footer seems fine:

  <script type="text/javascript" src="/sites/default/files/js/js_9ca15ca4d66b255b8c326fba276bdd39.jsmin.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "swfobject_api": { "files": { "swfobject-1": { "url": "http://php.opensourcecms.com/free/videos/drupal/drupal_blocks.swf", "params": { "type": "movie", "bgcolor": "#FFFFFF" }, "flashVars": [  ], "attributes": [  ], "height": "442", "width": "776", "express_redirect": "sites/all/modules/swfobject_api/expressinstall.swf", "version": "6", "bgcolor": null }, "swfobject-2": { "url": "/sites/all/plugins/jwflvmp/", "params": { "div_id": null, "allowFullScreen": null, "type": "movie", "bgcolor": "#FFFFFF" }, "flashVars": { "image": "/", "file": "http://php.opensourcecms.com/free/videos/drupal/drupal_blocks.swf", "autostart": "false" }, "attributes": [  ], "height": "442", "width": "776", "express_redirect": "sites/all/modules/swfobject_api/expressinstall.swf", "version": "6", "bgcolor": null } } } });
//--><!]]>
</script>

Did I mention the video is working and streaming? I'm still investigating why the error is still showing but figured I would share my results.

Anonymous’s picture

I was calling this from page.tpl.php, and then this line did not work:

drupal_add_js(drupal_get_path('module', 'swfobject_api') .'/swfobject.js', 'module', 'header'); in function swfobject_api_ensure_swfobject

Had to manually add such calls to tempalte.php instead.

tiato’s picture

I was able to get video tutorials working properly again and eliminated the "Sorry, you need to install flash player.." error by manually inserting SWFObject using a custom input format that allows PHP filtering. I have concluded that the issue is isolated to the Embedded Media Field module and not an issue with SWFObject API, however, I am updating this issue in case anyone else comes across the same issue.

I used a simple SWFObject call which works great:

  $url = "http://php.opensourcecms.com/free/videos/drupal/drupal_blocks.swf";
  $params = array(
    'width' => '776',
    'height' => '442',
  );
  
  print theme("swfobject_api", $url, $params);
Alan D.’s picture

In case people are using page.tpl.php - you wil never get this to work. It simply doesn't work that way :)

The $script & $closure variable is already created before the theme() function is called.

Anyway, another way (with a custom module) is:

<?php
/**
 * Implementation of hook_init().
 */
function xxx_init() {
  xxx_flash_header(); // empty for testing :)
}

function xxx_flash_header($url = "/sites/all/modules/swfobject_api/test.swf") {
  static $flash = NULL;
  if (empty($flash)) {
    $params = array('width' => 844, 'height' => 230, 'bgcolor' => '#777777' );
    $variables = array('foo' => 'bar');
    $flash = '<div id="flash-container">'. theme("swfobject_api", $url, $params, $variables) .'</div>';
  }
  return $flash;
}
?>

and then in your preprocess or theme ...

<?php
  // in your theme page.tpl.php
  print xxx_flash_header();
?>

This is to embed a single custom flash header.

hefox’s picture

Also, for inserting it into page.tpl.php rebuild $scripts and $closure after calling the theme function (like do it at the top of page.tpl.php before the variables are used).

This will be problamic though if a module/theme has overriden them (like 960 does), so careful

 $object =  theme("swfobject_api", $url, $params);
    $scripts =  drupal_get_js();
    $closure          = theme('closure');
nodestroy’s picture

What about overriding a theme function of ad_flash? There is a theme_ad_flash_swf_render which generates the output for the swf file. Overwriting this with phptemplate ends up with the same error as described above.

The theme function calls return theme("swfobject_api", $url, $params, $vars);
I dont know why, but the js code is not added to the $closure variable.

Putting the call of the new theme function into page.tpl.php, it works after calling $closure = theme('closure');
Is there a way to get this working?

tengoku’s picture

#22 work for me... but i think this is kinda yucky..

i need this on page.tpl.php.... can it be "preloaded" in template.php????

knalstaaf’s picture

I had the same problem when combining SWFObject API with FLV Media Player. Strangely enough, on the instruction page of FLV Media Player the module SWFObject API is mentionned at the very beginning of the guide. I followed all these steps, but with no result ("Sorry, you need to install flash player to see this content").

Since I simply disabled the SWFObject API module, the video's are working fine (with FLV Media Player). Makes you wonder what the point is of using SWFObject API, in this case. Is this an issue with SWFObject API, FLV Media Player (since it's still in beta), or is it just me that has done something wrong after all? Can't tell, really. All I know is that it's working now.

EDIT: I've followed the steps from the instruction page once more, but with the same result. Can't tell where it goes wrong, but if it could be of any use: here's a link to a page with an embedded video (SWFObject API module disabled atm). Since you're the author of both these modules, I tend to say that it must be me that has done something wrong (maybe in the node.tpl.php of page.tpl.php) of left something open, but I carefully followed the steps. So I can't tell.

TDFZ’s picture

Disabling the SWFObject API module fixed it for me. Thanks knalstaaf!!