How to serve/access a plugin-provided media/*swf file as a resource?


New member
I'm trying to package the Soundmanager2 javascript package as a resource-aware plugin (named "sound-manager-two" with ver="2.97a.20111220" because that's the soundmanager2 version I'm packaging) - I'm hoping this will be a replacement for the existing SoundManager plugin. I'm using using the resources-1.1.6 plugin with grails 1.3.7, and I need some help on how reference the 'soundmanager2.swf' file.

The plugin and my test "AudioGift" driver app are peer eclipse projects so I connect up the plugin in BuildConfig.groovy:
  grails.plugin.location.'sound-manager-two' = "../sound-manager-two"

The plugin will provide JS, CSS, and SWF resources:

In the GSP I do
<r:require modules="sm2,jquery"/>

I declared 'sm2' in the SoundManagerResource.groovy file:

modules = {
  sm2 {
    resource url:[plugin: 'sound-manager-two',
                  dir:'js', file:"soundmanager2.js"],
                  disposition:'head', nominify: true
   // tried adding an 'swf' module but resources plugin complains
   // Cannot create resource
   // /plugins/sound-manager-two-2.97a.20111220/media/soundmanager2.swf,
   // is not a supported type
  swf {
    dependsOn 'sm2'
    resource url:[plugin: 'sound-manager-two',
                  dir:'media', file:'soundmanager2.swf']
                  // tried with and without adding attrs:[type:'js']
 // flashblock and inlineplayer module definitions, etc

Now the soundmanager2.js library loads up into the page, from:

but soundmanager2 immediately looks for its soundmanager2.swf file; it gets a '404' because that SWF is not in the default location, so soundmanager does a timeout and tries to load the SWF later, from a parameterized location (the directory of SWF files, then soundmanager chooses a specific SWF from there). Thus, I need to set the parameter URL to the SWF which is a one-liner in jQuery; and that URL to the SWF is what I can't get to work - everything I've tried comes back '404' even when I write out the entire URL myself:

    <script type="text/javascript">	
          soundManager.url = 'http://localhost:8080/AudioGift/static/plugins/sound-manager-two-2.97a.20111220/media/'
          // = 'http://localhost:8080/AudioGift/plugins/sound-manager-two-2.97a.20111220/media/'

I have looked in the working dir and indeed I don't see the media dir at all:

~/.grails/1.3.7/projects/AudioGift/tomcat/work/Tomcat/localhost/AudioGift/grails-resources/plugins/sound-manager-two-2.97a.20111220 $ tree
├── css
│** ├── flashblock.css
│** └── inlineplayer.css
├── images
│** ├── icon_pause.gif
│** ├── icon_pause.png
│** ├── icon_play.gif
│** └── icon_play.png
└── js
    ├── flashblock.js
    ├── inlineplayer.js
    └── soundmanager2.js
Last edited: