Continuously sound for next sections

Hi, well, i'm new to squiffy and
and i'm going to say first: sorry for my bad english. i hope u guys can understand what i'm saying. lol.

i want bgm for some 'sections', and other for others sections. (attention for the bolds :))

but when i use

<audio autoplay src="somemusic.mp3" />

the sound only play in this section, when i go to the other it's abruptly stopping..
i try to use the master section, and this goes worse because the music starts to sounds twice..
or the music pause and start for the beginning..

If you have a code sample please help me :(

Have you tried declaring your audio in the html template with:

<audio id="mysound" src="sound.mp3" preload="auto"></audio>

And then calling it from sections with the Javascript function:


That might solve your problem and is a cleaner way of calling sound anyway.


Thanks for replied me :)

The function you gave me works fine, but it's there a function that can works continuously with the function @clear ?

When i use @clear the sound function is canceled.. u.u

I haven't tried this, so take it with a grain of salt, but why not use an Audio object instead of a tag? Like this:

	squiffy.set("music", new Audio("path/to/sound-file.ogg"));

That way your audio object should survive any change in display, since it's stored as a Squiffy attribute, and those last the entire game.


Thanks for the reply :D!

I tried to use the code you give like:

    squiffy.set("music", new Audio("somemusic_inthesamefolder.mp3"));


but it's shows "SyntaxError: Unexpected token {"

And i tried to test some codes with the attribute.. but i failed.. :(

This topic is now closed. Topics are closed after 60 days of inactivity.