WebAudio Class
The audio object of Web Audio API.
Constructor
WebAudio ( url )
Parameters:
-
url
StringThe url of the audio file
Item Index
Methods- addLoadListener
- addStopListener
- canPlayM4a static
- canPlayOgg static
- clear
- fadeIn
- fadeOut
- initialize static
- isError
- isPlaying
- isReady
- play
- seek
- stop
Methods
addLoadListener ( listner )
Add a callback function that will be called when the audio data is loaded.
Parameters:
-
listner
FunctionThe callback function
addStopListener ( listner )
Add a callback function that will be called when the playback is stopped.
Parameters:
-
listner
FunctionThe 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
NumberFade-in time in seconds
fadeOut ( duration )
Performs the audio fade-out.
Parameters:
-
duration
NumberFade-out time in seconds
initialize ( noAudio ) Boolean [static]
Initializes the audio system.
Parameters:
-
noAudio
BooleanFlag 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
BooleanWhether the audio data play in a loop
-
offset
NumberThe 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.