WebAudio Class

The audio object of Web Audio API.

Constructor

WebAudio ( url )

Parameters:

  • url String

    The url of the audio file

Item Index

Methods Properties

Methods

addLoadListener ( listner )

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

Parameters:

  • listner Function

    The callback function

addStopListener ( listner )

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

Parameters:

  • listner Function

    The callback function

canPlayM4a () Boolean [static]

Checks whether the browser can play m4a files.

Returns:

Boolean:
True if the browser can play m4a files

canPlayOgg () Boolean [static]

Checks whether the browser can play ogg files.

Returns:

Boolean:
True if the browser can play ogg files

clear ()

Clears the audio data.

fadeIn ( duration )

Performs the audio fade-in.

Parameters:

  • duration Number

    Fade-in time in seconds

fadeOut ( duration )

Performs the audio fade-out.

Parameters:

  • duration Number

    Fade-out time in seconds

initialize ( noAudio ) Boolean [static]

Initializes the audio system.

Parameters:

  • noAudio Boolean

    Flag for the no-audio mode

Returns:

Boolean:
True if the audio system is available

isError () Boolean

Checks whether a loading error has occurred.

Returns:

Boolean:
True if a loading error has occurred

isPlaying () Boolean

Checks whether the audio is playing.

Returns:

Boolean:
True if the audio is playing

isReady () Boolean

Checks whether the audio data is ready to play.

Returns:

Boolean:
True if the audio data is ready to play

play ( loop , offset )

Checks whether the audio data is ready to play.

Parameters:

  • loop Boolean

    Whether the audio data play in a loop

  • offset Number

    The start position to play in seconds

seek ()

Gets the seek position of the audio.

stop ()

Stops the audio.

Properties

pan Number

The pan of the audio.

pitch Number

The pitch of the audio.

url String

[read-only] The url of the audio file.

volume Number

The volume of the audio.