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

wstidolph

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:
Code:
  grails.plugin.location.'sound-manager-two' = "../sound-manager-two"

The plugin will provide JS, CSS, and SWF resources:
Code:
/web-app/js/soundmanager2.js
/web-app/media/soundmanager2.swf
/web-app/css/...

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

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

Code:
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:
Code:
   http://localhost:8080/AudioGift/static/plugins/sound-manager-two-2.97a.20111220/js/soundmanager2.js

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:

Code:
    <script type="text/javascript">	
        $(document).ready(function(){
          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/'
        });
    </script>

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

Code:
~/.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:
Top