multishot problem in latest sm2?
Just upgraded to the latest version of soundmanager2 (2008-10-28) and encountered a new problem with multiShot mode. It seems that when sound.onfinish is run, the setPosition(0) call on line 1190 of soundmanager2.js resets the position for all currently playing instances of the sound, not only the one which just reached its end. If I comment that line out, then all of my multiShot sounds seem to work fine again.
Is it safe to just comment that line out? Thanks!
Is it safe to just comment that line out? Thanks!
2
people have this problem
I have this problem, too!
Tell me when someone solves it.
The more people who report this problem, the more it gets noticed.
The more people who report this problem, the more it gets noticed.
The company marked this problem solved.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Commenting out the setPosition() call from line 1190 should be safe, though it may mean the position may not properly "reset" to 0 when the sound finishes.
This change (line 1190) was a fix for a previous setPosition-related bug where the position was not being set back to 0 after the sound had completed - I had forgotten about multiShot use cases.
SM2 should call setPosition(0) presumably only after all instances have finished, because it seems to affect all playing instances as you noticed. Good find! :) I should have a fix which you can test/verify for the next release.
You can try replacing this function within soundmanager2.js, within the SMSound object:
this._onfinish = function() {
// sound has finished playing
_t.playState = 0;
_t.paused = false;
if (_t._iO.onfinish) {
_s._wD('SMSound._onfinish(): "'+_t.sID+'"');
_t._iO.onfinish.apply(_t);
}
if (_t._iO.onbeforefinishcomplete) _t._iO.onbeforefinishcomplete.apply(_t);
// reset some state items
// _t.setPosition(0); // *** old ***
_t.didBeforeFinish = false;
_t.didJustBeforeFinish = false;
if (_t.instanceCount) {
_t.instanceCount--;
if (!_t.instanceCount) {
// reset instance options
_t.setPosition(0); // *** new ***
_t.instanceCount = 0;
_t.instanceOptions = {};
}
}
};
All that should be needed is to move the setPosition(0) call into the IF block where instanceCount becomes 0, indicating all instances of the sound have finished playing.
I’m amused
-
Inappropriate?Thanks for the quick reply!! I tried the new function in your code sample, but the problem persists even with the setPosition moved to the if statement -- not sure why since the rationale for that solution makes sense. Anyways, just leaving it completely commented out works fine for me for now...my code's not dependent on the position being reset.
If I can be of any further debugging/testing assistance, just let me know. -
Inappropriate?I've released an updated version of SM2 which includes the above block, in the event there is a chance setPosition(0) may not have been previously called.
If you have a live/public demo URL which shows some of the behaviour described, I can try testing it there as well. The MPC demo I have does use onfinish() and it seems to fire without stopping other instances of the sound, but maybe there's something different in the way you're calling play(), etc. -
Inappropriate?Updated to the new version, but still having the same problem. Code is not available on a public site at the moment but I will get it up soon and let you know. THanks again for your help!
-
Inappropriate?Updated to the new version, but still having the same problem. Code is not available on a public site at the moment but I will get it up soon and let you know. THanks again for your help!
-
Inappropriate?Version 2.92 is out which has some onfinish()/setPosition()-related changes which may have resolved this bug, but I'm not 100% on how to reproduce it as you've described. If you have a minimal code example which can demonstrate it, that'd be excellent.
1 person says
this solves the problem
-
Scott -- thanks, everything is working great with the new update! -
Inappropriate?I have been noticing the same issue. when i start the same sound multiple times, the sound is stopped and restarted every time. I was expecting to here multiple instances of the sound. following code leads to the issue. I might just be doing something wrong here, would appreciate a kick in the right direction.
soundManager.onload = function() {
soundManager.createSound({
id: 'whistle',
url: '/snd/whistle.mp3',
});
setTimeout("soundTest()",1000);
}
function soundTest(){
soundManager.play('whistle',{multiShot: true});
setTimeout("soundTest()",Math.random()*1000);
} -
Inappropriate?I think I must have missed and need to explain this better in the API/documentation as I missed it myself when looking - only the flash 9+ version supports multiShot.
Thus, make sure you're using soundManager.flashVersion = 9;
"multiShotEvents" also allows for the onfinish() to fire for each sound, for example (check #4 which shows multiShotEvents).
http://www.schillmania.com/projects/s...
-
Inappropriate?found the problem....
soundManager.url = '/java/sm2/swf/soundmanager2.swf'
should have been
soundManager.url = '/java/sm2/swf/'
i was using code from an earlier project and didnt notice the change ;) ...
works like a charm.
1 person says
this solves the problem
-
Ah yes, SM2 does not rewrite the URL if you specify a full one including the .SWF bit. Either way, good to know it's been solved.
Loading Profile...



EMPLOYEE