Audio script interface

The IAudioObjectType interface derives from IObjectClass to add APIs specific to the Audio plugin.

The script interface essentially just provides access to the underlying AudioContext (part of the Web Audio API) that the Audio plugin uses internally for audio playback. However this is sufficient to provide complete control over audio playback, including setting up complex graphs of audio processing nodes. It is also convenient, since Construct manages some awkward details such as ensuring playback is enabled as soon as possible given most browsers impose autoplay restrictions. Adding the Audio object and using its script interface saves you from having to re-implement these details yourself.

Note this class derives from the object class interface, not the instance interface. Typically it is used through runtime.objects.Audio.

Examples

The following examples demonstrate using the Web Audio API for audio playback.

Audio APIs

audioContext
The Audio plugin's internal AudioContext used for audio playback.
destinationNode
The destination node to connect any additional audio nodes to.

isSilent
Set or get a boolean indicating whether Silent mode is enabled. In silent mode all currently playing sounds are muted and no new sounds will play.
masterVolume
Set or get the current master volume, which is applied to all audio playback, in dB.
stopAll()
Stop all currently playing sounds.
Construct 3 Manual 2024-09-17

On this page