SoundManager2 Rails - Only Last Song Plays
Greetings,
I am trying to implement SoundManager2 into a rail application. See code below.
The page loads fine with this code, listing each of the tracks on a given playlist and displaying a play button next to each track.
However only, the last track is actually playable.
Clicking on any other, but the last track results in "Name of Track" is an invalid sound ID.
Any ideas on what I am doing wrong or suggestions for alternative solutions would be greatly appreciated.
Thanks,
Scott
I am trying to implement SoundManager2 into a rail application. See code below.
<% @playlist.tracks.each do |track| %>
<% sound = [[track.title, track.song.url]] %><%= toggle_sound track.title %><%= initialize_sounds(sound, debug=true) %>
<%= track.title %>
<% end %>
The page loads fine with this code, listing each of the tracks on a given playlist and displaying a play button next to each track.
However only, the last track is actually playable.
Clicking on any other, but the last track results in "Name of Track" is an invalid sound ID.
Any ideas on what I am doing wrong or suggestions for alternative solutions would be greatly appreciated.
Thanks,
Scott
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
The company marked this question as answered.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?I would check your SM2 syntax, and make sure that you are passing a proper string to the createSound() and play() methods. The sound ID string must be usable as an array index, so it should not start with a number or have any funny characters in it.
Depending on how you wrote your code, you should have something like the following (create and play at once, or in two methods):
soundManager.play('sound1','/path/to/first-sound.mp3'); // ID and URL
Or, in { object literal } style:
soundManager.createSound({
id: 'sound1',
url: '/path/to/first-sound.mp3'
});
// .. later.. soundManager.play('sound1');
More create/play examples on the API demo page:
http://www.schillmania.com/projects/s...
My suggestion is to use a simple incrementing value from Rails within your loop for the sound ID, eg. sound0, sound1, sound2 etc.
The company says
this answers the question
Loading Profile...



EMPLOYEE