Apologies for no Fiddle; just trying to understand SoundManager 2's basics and failing miserably.
Why doesn't this work:
<script>
soundManager.setup({
url: 'swf/',
preferFlash: false,
onready: function() {
// Ready to use; soundManager.createSound() etc. can now be called.
}
});
</script>
<script>
$(document).ready(function() {
soundManager.createSound({
id: 'mySound',
url: 'audio/sound.mp3',
autoLoad: true,
autoPlay: true,
volume: 50
});
mySound.play();
});
</script>
But this does:
<script>
soundManager.setup({
url: 'swf/',
preferFlash: false,
onready: function() {
soundManager.createSound({
id: 'mySound',
url: 'audio/mySound.mp3',
autoLoad: true,
autoPlay: true,
volume: 50
});
mySound.play();
}
});
</script>
I don't get it... at all. Does every sound have to be loaded into onready()? And if so, how is that remotely useful for 90% of use cases? I have to be missing something. The examples they provide make it seem as easy putting this anywhere in my code:
soundManager.createSound({
id: 'mySound2',
url: 'audio/mySound2.mp3'
});
soundManager.play('mySound2');
Yet it doesn't work. Why?