Class in reactor_core_io.js

WebAudio

16 public functions in 4 groups · show internal (_) functions

The Database: everything Core loads at boot.

Familiar territory. WebAudio keeps the RPG Maker MZ API, so existing MZ knowledge, tutorials and plugin code apply. Reactor's additions are marked with descriptions below.

The audio object of Web Audio API.

@class
@param
url string The url of the audio file.
function WebAudio()

Quick Reference

Setup & Creation 2

initialize() Sets up a new instance.
initialize() Initializes the audio system.

Checks (True / False) 3

isReady() Checks whether the audio data is ready to play.
isError() Checks whether a loading error has occurred.
isPlaying() Checks whether the audio is playing.

Actions 9

setMasterVolume() Sets the master volume for all audio.
clear() Clears the audio data.
play() Plays the audio.
stop() Stops the audio.
destroy() Destroys the audio.
fadeIn() Performs the audio fade-in.
fadeOut() Performs the audio fade-out.
addLoadListener() Adds a callback function that will be called when the audio data is loaded.
addStopListener() Adds a callback function that will be called when the playback is stopped.

Other 2

seek() Gets the seek position of the audio.
retry() Tries to load the audio again.

Setup & Creation

initialize

method source
WebAudio.prototype.initialize(url)

Sets up a new instance. (Same as the RPG Maker MZ method of this name.)

initialize

static source
WebAudio.initialize()

Initializes the audio system.

Details

Initializes the audio system.

@returns
boolean True if the audio system is available.

Checks (True / False)

isReady

method source
WebAudio.prototype.isReady()

Checks whether the audio data is ready to play.

Details

Checks whether the audio data is ready to play.

@returns
boolean True if the audio data is ready to play.

isError

method source
WebAudio.prototype.isError()

Checks whether a loading error has occurred.

Details

Checks whether a loading error has occurred.

@returns
boolean True if a loading error has occurred.

isPlaying

method source
WebAudio.prototype.isPlaying()

Checks whether the audio is playing.

Details

Checks whether the audio is playing.

@returns
boolean True if the audio is playing.

Actions

setMasterVolume

static source
WebAudio.setMasterVolume(value)

Sets the master volume for all audio.

Details

Sets the master volume for all audio.

@param
value number The master volume (0 to 1).

clear

method source
WebAudio.prototype.clear()

Clears the audio data.

play

method source
WebAudio.prototype.play(loop, offset)

Plays the audio.

Details

Plays the audio.

@param
loop boolean Whether the audio data play in a loop.
@param
offset number The start position to play in seconds.

stop

method source
WebAudio.prototype.stop()

Stops the audio.

destroy

method source
WebAudio.prototype.destroy()

Destroys the audio.

fadeIn

method source
WebAudio.prototype.fadeIn(duration)

Performs the audio fade-in.

Details

Performs the audio fade-in.

@param
duration number Fade-in time in seconds.

fadeOut

method source
WebAudio.prototype.fadeOut(duration)

Performs the audio fade-out.

Details

Performs the audio fade-out.

@param
duration number Fade-out time in seconds.

addLoadListener

method source
WebAudio.prototype.addLoadListener(listner)

Adds a callback function that will be called when the audio data is loaded.

Details

Adds a callback function that will be called when the audio data is loaded.

@param
listner function The callback function.

addStopListener

method source
WebAudio.prototype.addStopListener(listner)

Adds a callback function that will be called when the playback is stopped.

Details

Adds a callback function that will be called when the playback is stopped.

@param
listner function The callback function.

Other

seek

method source
WebAudio.prototype.seek()

Gets the seek position of the audio.

retry

method source
WebAudio.prototype.retry()

Tries to load the audio again.