Class: WebAudio

WebAudio

new WebAudio (url)

The audio object of Web Audio API.

Name Type Description
url string

The url of the audio file.

Members

pan number

The pan of the audio.

pitch number

The pitch of the audio.

url string readonly

The url of the audio file.

volume number

The volume of the audio.

Methods

WebAudio.initialize ()boolean static

Initializes the audio system.

Returns:
Type Description
boolean True if the audio system is available.

WebAudio.setMasterVolume (value) static

Sets the master volume for all audio.

Name Type Description
value number

The master volume (0 to 1).

addLoadListener (listner)

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

Name Type Description
listner function

The callback function.

addStopListener (listner)

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

Name Type Description
listner function

The callback function.

clear ()

Clears the audio data.

destroy ()

Destroys the audio.

fadeIn (duration)

Performs the audio fade-in.

Name Type Description
duration number

Fade-in time in seconds.

fadeOut (duration)

Performs the audio fade-out.

Name Type Description
duration number

Fade-out time in seconds.

isError ()boolean

Checks whether a loading error has occurred.

Returns:
Type Description
boolean True if a loading error has occurred.

isPlaying ()boolean

Checks whether the audio is playing.

Returns:
Type Description
boolean True if the audio is playing.

isReady ()boolean

Checks whether the audio data is ready to play.

Returns:
Type Description
boolean True if the audio data is ready to play.

play (loop, offset)

Plays the audio.

Name Type Description
loop boolean

Whether the audio data play in a loop.

offset number

The start position to play in seconds.

retry ()

Tries to load the audio again.

seek ()

Gets the seek position of the audio.

stop ()

Stops the audio.