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.
Comment | File | Size | Author |
---|---|---|---|
#6 | 407142.patch | 798 bytes | George2 |
Comments
Comment #1
arthurf CreditAttribution: arthurf commentedwould you mind giving me a URL that I could look at where the code isn't working?
Comment #2
titouilleSorry but this is on a local installation. I'll see if I can put it on my local server and give you an url ;-)
Comment #3
arthurf CreditAttribution: arthurf commentedIf 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.
Comment #4
titouilleRe,
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 :-|
Comment #5
arthurf CreditAttribution: arthurf commentedI'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
Comment #6
George2 CreditAttribution: George2 commentedi 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:
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
Comment #7
arthurf CreditAttribution: arthurf commentedAs 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.
Comment #8
George2 CreditAttribution: George2 commentedif 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.
Comment #9
arthurf CreditAttribution: arthurf commentedWhy 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?
Comment #10
arthurf CreditAttribution: arthurf commentedAlso, 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 ;)
Comment #11
George2 CreditAttribution: George2 commentedbah humbug :p
Comment #12
LateNightDesigner CreditAttribution: LateNightDesigner commentedI'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:
Comment #13
SeanBannister CreditAttribution: SeanBannister commentedI can confirm this problem and my $scrips is displayed above $closure
Comment #14
robotjox CreditAttribution: robotjox commentedconfirming too
Comment #15
arthurf CreditAttribution: arthurf commentedWhat is the js that is being printed on your page?
Comment #16
BlindWolf8 CreditAttribution: BlindWolf8 commentedHello,
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!
Comment #17
BlindWolf8 CreditAttribution: BlindWolf8 commentedPS: 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?
Comment #18
tiato CreditAttribution: tiato commentedI 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:
After #12 is applied and the video is working (streaming again), the output is not much different:
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:
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.
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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');
infunction swfobject_api_ensure_swfobject
Had to manually add such calls to tempalte.php instead.
Comment #20
tiato CreditAttribution: tiato commentedI 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:
Comment #21
Alan D. CreditAttribution: Alan D. commentedIn 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:
and then in your preprocess or theme ...
This is to embed a single custom flash header.
Comment #22
hefox CreditAttribution: hefox commentedAlso, 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
Comment #23
nodestroy CreditAttribution: nodestroy commentedWhat 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?
Comment #24
tengoku#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????
Comment #25
knalstaaf CreditAttribution: knalstaaf commentedI 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.
Comment #26
TDFZ CreditAttribution: TDFZ commentedDisabling the SWFObject API module fixed it for me. Thanks knalstaaf!!