| Path: | README |
| Last Update: | Thu Mar 06 17:56:54 -0500 2008 |
This is a wrapper around Scott Schill‘s SoundManager2 Javascript API (www.schillmania.com/projects/soundmanager2/).
Use the supplied generator to install the SoundManager2 Javascript and Flash files in your Rails app like this:
./script/generate sound_manager2
This will create the following files:
public/soundmanager2.swf public/javascripts/soundmanager2.js public/javascripts/soundmanager2-jsmin.js public/javascripts/soundmanager2-rails.js public/images/SoundManager2/pause-control.gif public/images/SoundManager2/play-control.gif
Then, to add basic play/stop functionality to your view, add the following to your ERB files:
<%= javascript_include_tag :defaults %> <%
sounds = [
["sound1", "http://url/to/sound1.mp3"],
["sound2", url_for(:controller => "sounds", :action => "listen", :id => "2")],
]
%> <%= initialize_sounds(sounds) %>
<div>Play sound 1: <%= toggle_sound "sound1" %></div> <div>Play sound 2: <%= toggle_sound "sound2" %></div>
And that‘s it! You can use as much or as little of SoundManager2‘s API directly, but I hope to add a complete API wrapper eventually.
Copyright (c) 2008 Lawrence J. Karnowski, released under the MIT license