Audio.Sound Class
Sound class is object represent html5 sound tag.
Constructor
Audio.Sound
-
src
Parameters:
-
src
String | StringThe sound source url. If an array is passed, the first supported source is used, so provide the same sound in many formats is recommended.
Item Index
Methods
Methods
_choosePath
-
sources
choose a compatible source for audio tag.
Parameters:
-
sources
String | Stringurl or array of urls for source audio file.
Returns:
null
otherwise.
_playFailed
()
private
Called when an error occurs for cleaning audio tag.
_updateVolume
()
private
Applies all volume modifications.
getDuration
()
Number
Get current sound duration.
Returns:
getPosition
()
Number
Get current sound offset.
Returns:
getVolume
()
Number
Get current sound volume.
Returns:
load
-
offset
-
loop
-
volume
Load sound and call onReady
callback when load finish.
Parameters:
-
offset
NumberThe offset where sound start.
-
loop
NumberThe number of loop where sound played.
-
volume
NumberThe volume of sound.
Returns:
mute
-
isMuted
Mute or Unmute all sound in this channel.
Parameters:
-
isMuted
BooleanTrue for mute or false for unmute.
mute
-
value
Set current sound volume.
Parameters:
-
value
Numbersound volume, between 0.0 and 1.0.
pause
()
Pause sound.
play
()
Start play sound.
resume
()
Resume sound.
setPosition
-
value
Set current sound offset.
Parameters:
-
value
NumberThe value of offset.
stop
()
Stop sound.
Properties
_muted
Boolean
private
Mute state.
Default: false
_volume
Number
private
Audio volume, between 0.0 and 1.0
Default: 1.0
audio
Object
Html5 tag audio capabilities. Indicates for each format if it is supported by the navigator.
Supported format are mp3, ogg and wav.
Example:
{ mp3: true, ogg: false, wav: true }
audio
Object
Html5 tag audio.
offset
Number
private
Audio offset.
Default: 0
onComplete
Function
Callback function when sound play is complete.
Default: null
onLoop
Function
Callback called when sound play restart loop.
Default: null
onReady
Function
Callback called when sound is ready to play.
Default: null
paused
Boolean
Pause state.
Default: false
playState
String
Audio play state.
Default: null
remainingLoops
Number
Number of loop remaining to play.
Default: 0
src
String
Audio source file, used by the audio element.
Even if many paths are passed to constructor, src
contain only that which is currently used.