Audio and music
AB has some functions to support audio and music:
AB.backgroundMusic ( musicfile ); // play background music, draw buttons, return audio object
AB.standardAudioButtons ( audio ); // draw standard play/pause buttons for this audio
AB.audioIsPlaying ( audio ); // return if this audio is currently playing
Audio autoplay on web pages
There is a basic issue with audio which is that all these Worlds are
web pages.
Audio automatically playing on web pages can be annoying.
As a result, in some browsers (especially mobile browsers)
audio will not automatically play
but requires
user interaction to start it.
The
Starter Worlds that have background music
have "play" and "pause" buttons for manual control if the music does not start.
A better solution is a
splash screen
to get a user interaction (a click) at the start of the run.
Then background music can start,
and audio events can be set up that can be triggered by the JS later for sound effects
without further user interaction.
See notes on
Audio for Web games.
Here are some sample Worlds that use user interaction (on a splash screen)
to start background music and set up audio events for later:
Bouncy Balls 536 runs ♦ 3 likes
By
Starter user Created: 1 Oct 2017
Modified: 17 Sep 2023
Demo of Physics API. Balls bounce under gravity and collide in low friction world. Splash screen... Castle World 801 runs ♦ 4 likes
By
Starter user Created: 11 Nov 2016
Modified: 17 Sep 2023
Demo of how to insert 3d model into World. Mind-controlled agent, actively-pursuing enemy. Splas... Zombie Death Baby 810 runs ♦ 1 like
By
Starter user Created: 11 Jun 2018
Modified: 17 Sep 2023
How to make a fun touch game for mobile. Touch drag and tap objects. Mouse drag and click object... Collision World 1462 runs ♦ 4 likes
By
Starter user Created: 21 Sep 2017
Modified: 17 Sep 2023
Demo of Physics API. Blocks fall under gravity and collide. Can modify gravity, friction, etc. S...