sm2 not playing slow-loading mp3 with autoload:true and timed play()
I'm using sm2 (beautiful, thanks) on a flashcard site (wossis.com). I use soundManager.createSound(autoPlay:false, autoLoad:true) to load an mp3 when the card loads. A js timer fades up the card caption a few seconds after the image, and calls sound.play() to for the caption sound. It worked fine, until TM borked my DSL line. Over an EDGE connection (UK server, my desktop in Malaysia - a very bad scenario), the sounds don't play when triggered by js, but will a few seconds later with a click handled by sound.play()
I added (to a test server on my desk) a 4-second delay _only_ before the mp3 is served, and got the same result. I'm guessing play() doesn't 'know' the mp3 file is being loaded. I changed 'autoLoad:false', which gets around the problem - but that will delay sound loading for all clients. I had a look through the sm2 API, but didn't see anything that might help play() 'notice' that the sound is being loaded. Could play wait for autoLoads to finish?
The mp3s are very short - typically 4kB to 8kB, but EDGE is slow during the day here (I'd be surprised if it was better than 1-2kB/s), and latency will be dire - almost certainly above 1 second - even for name resolution. I can't easily check: my EDGE ISP, while very reliable, blackholes network diagnostics.
Edit - is this the same as:
http://getsatisfaction.com/schillmani...
...only not as detailed?
I added (to a test server on my desk) a 4-second delay _only_ before the mp3 is served, and got the same result. I'm guessing play() doesn't 'know' the mp3 file is being loaded. I changed 'autoLoad:false', which gets around the problem - but that will delay sound loading for all clients. I had a look through the sm2 API, but didn't see anything that might help play() 'notice' that the sound is being loaded. Could play wait for autoLoads to finish?
The mp3s are very short - typically 4kB to 8kB, but EDGE is slow during the day here (I'd be surprised if it was better than 1-2kB/s), and latency will be dire - almost certainly above 1 second - even for name resolution. I can't easily check: my EDGE ISP, while very reliable, blackholes network diagnostics.
Edit - is this the same as:
http://getsatisfaction.com/schillmani...
...only not as detailed?
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 might try using stream:false when creating the sounds in this case, which means that the sound will not start playing until the whole thing has loaded. (stream is set to true by default as it will benefit everyone else, etc.)
Another option could be to make a function that will only play a sound if more than 50% of it has loaded, or something, in this case. This pseudocode might work as-is when a sound has stream:true..
function playIfHalfLoaded(soundID) {
var s = soundManager.sounds[soundID];
if (s && s.bytesLoaded && s.bytesLoaded >= (s.bytesTotal/2)) {
// 50%+ has loaded, OK to play?
s.play();
}
}
If the files are small, it may be best to start preloading them ASAP and perhaps skip playing them if not loaded 100% - unless sound is critical to your app.
The company and 1 other person say
this answers the question
-
streamed:false didn't seem to make any difference - these are very small files. I moved the createSound into an inline head script (re your ASAP suggestion) and the timed play function now polls bytesLoaded for a short 'window of optimism'. Sound isn't so much critical to the app as reliably-sound/reliably-nosound is!
The kludge should take care of those unlucky enough to try using the site with a really awful Internet connection, but still delivers the pre-load to everybody else. Thanks for the bytesLoaded heads-up. -
Inappropriate?Note that it's "stream:false" and not "streamed:false" just to be certain, the latter will not work.
eg.
soundManager.createSound({
id: 'mySound',
url: '/path/to/some.mp3',
stream: false
});
soundManager.play('mySound'); // should only play when loaded 100%.
Actually, it looks like I have a bug here - when play() is called with either flash version 8 or 9, stream may end up being overridden or ignored with the assumption that the user wants to get the sound playing ASAP. This isn't right. I have something to fix for the next version, I guess. ;)
Loading Profile...



EMPLOYEE