Pause background looping sound
Shri

Hi,

 

I have a sound which plays in the background of a game level.

I load it using  - wade.preloadAudio(soundName);

Then when the level begins, it plays using wade.playAudioIfAvailable(soundName,true)

The second parameter sets the sound to loop.

Everything seems to be working fine.

 

When the level ends or the game restarts, I would like to pause the sound

I don't want to unload the sound using wade.unloadAudio() because I plan on starting it again.

I have tried:

audio = wade.getAudio(sound)

bgSound = new Audio(audio.src);

bgSound.pause();

 

and

wade.getAudio('sound').pause();

 

The tutorials and documentation are not really clear on how to stop a sound temporarily.

Any help you can provide would be appreciated.

 

cheers,

All 5 Comments
Gio
You are absolutely right, it seems that when we rewrote the audio system we completely overlooked the ability to pause, resume and restart sounds.

Prior to WADE 0.9 you could use wade.getAudio() to do that, but now wade.getAudio() has been deprecated and will shortly be removed. This is because it used to give you access to an html5 Audio object, but with the new system WADE tries to avoid using html5 Audio objects, replacing them with the more powerful WebAudio Buffers in browsers that support them.

wade.getAudio() may do what you want in some browsers, but not in some others. So don't use it.

If you can wait a couple of days, we'll try to add the functions you need to WADE 1.0.2, which we were going to release this week anyway.

Thanks for bringing this problem to our attention.
Gio

We released 1.0.2 yesterday, now you can do this:

var mySound = wade.playAudio('myFile.ogg');wade.stopAudio(mySound);
Shri

Gio,

 

Thanks for the fix, I updated the game and everything seems to be working as advertised.

I was going to upload the game to the forum, but my upload limit is 256K now when before it was 500K?

With the sounds, the game zip is over 300K so what gives with the uploading size?

Should I just wait until the other method to release game comes online?

 

cheers,

Shri

Gio

Apologies for the confusion, it was just me trying to change the upload limit without really knowing what I was doing :)

 

I've now sought some advice and hopefully fixed it. However I'm told that we can't set a limit per attachment, just a global limit (i.e. a limit for the size of all your uploads, all together). I've now set this limit to 2MB, give me a shout if it isn't enough. The limit is really only there to prevent spammers from messing with our web server, but when you're posting games and useful things we can certainly make exceptions!

Gio

Also I would like to ask if you can include wade_1.0.2.js in your zip file, so it's easier for people to try your game.

Post a reply
Add Attachment
Submit Reply
Login to Reply