Hi,

Is it possible to AUTOMATICALLY display an audio player if a mp3 is attached to a node ? How can I do that ? Thanks for your help.

Comments

vstmusic’s picture

In other words, how convert file attachments to a playlist ?

Stuart Greenfield’s picture

Status: Active » Postponed

There was a prototype module for this with SWF Tools 5, but it was always tagged as "unstable". I haven't ported it to SWF Tools 6 yet as I'm trying to get the core modules settled down. At the moment you'd need to write some custom code (php) in to your node to access the file attachment and call the necessary swf() or swf_list() functions.

I'm going to change this thread to postponed as I don't have any time in the short term to work on a new version of the integration module, but I'm hoping I'll get round to it at some point...

vstmusic’s picture

Do yo know an example of this "custom code (php)" ? I did not see that in the module's documentation.

Stuart Greenfield’s picture

You need to write it on a node-by-node basis, so it isn't really automatic, but you could use the SWF Tools input filter and just refer to the filename, or you could use PHP code like


if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
  $node = node_load(arg(1));
  $file_data = array_pop($node->files);
  $filepath = $file_data->filepath;
  print swf($filepath);
}

Seeing that written down, it isn't exactly intuitive, so maybe I need to revisit the integration module!

vstmusic’s picture

Thanks, but your code, writing in my node.tpl.php file display the player, but it does not find the audio file. If I check the code of my html page, it is :

<object data="http://www.mysite.org/sites/all/modules/swftools/shared/1pixelout/player.swf" id="swfswfobject2-id-12270333691" type="application/x-shockwave-flash" width="290" height="24"><param value="default" name="swliveconnect"><param value="true" name="play"><param value="false" name="loop"><param value="false" name="menu"><param value="autohigh" name="quality"><param value="showall" name="scale"><param value="l" name="align"><param value="tl" name="salign"><param value="opaque" name="wmode"><param value="#FFFFFF" name="bgcolor"><param value="7" name="version"><param value="true" name="allowfullscreen"><param value="http://www.mysite.org/sites/default/files/" name="base"><param value="http://www.www.mysite.org/sites/all/modules/swftools/shared/1pixelout/player.swf" name="src"><param value="24" name="height"><param value="290" name="width"><param value="autostart=no&amp;loop=no&amp;soundFile=http://www.mysite.org/sites/default/files/test.mp3" name="flashvars"></object>
<script type="text/javascript">
swfobject.embedSWF("http://www.mysite.org/sites/all/modules/swftools/shared/1pixelout/player.swf", "swfobject2-id-12270333691", "290", "24", "7", "", { "autostart": "no", "loop": "no", "soundFile": "http://www.mysite.org/sites/default/files/test.mp3" }, { "swliveconnect": "default", "play": "true", "loop": "false", "menu": "false", "quality": "autohigh", "scale": "showall", "align": "l", "salign": "tl", "wmode": "opaque", "bgcolor": "#FFFFFF", "version": "7", "allowfullscreen": "true", "base": "http://www.mysite.org/sites/default/files/", "src": "http://www.mysite.org/sites/all/modules/swftools/shared/1pixelout/player.swf", "height": 24, "width": 290 }, { "id": "swfswfobject2-id-12270333691" });
</script> 

Can you help me ?

vstmusic’s picture

I believe that the probem is here :

<param value="autostart=no&amp;loop=no&amp;soundFile=http://www.mysite.org/sites/default/files/test.mp3" name="flashvars">

no ? what is "&" here ? Is it normal ?