API Docs for: 0.3.0
Show:

Audio.Sound Class

Module: Audio

Sound class is object represent html5 sound tag.

Constructor

Audio.Sound

(
  • src
)

Parameters:

  • src String | String

    The sound source url. If an array is passed, the first supported source is used, so provide the same sound in many formats is recommended.

Methods

_choosePath

(
  • sources
)
String private

choose a compatible source for audio tag.

Parameters:

  • sources String | String

    url or array of urls for source audio file.

Returns:

String: the first copmpatible url if any; 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:

Number: A current sound duration.

getPosition

() Number

Get current sound offset.

Returns:

Number: A current sound offset.

getVolume

() Number

Get current sound volume.

Returns:

Number: A current sound volume.

load

(
  • offset
  • loop
  • volume
)
Boolean

Load sound and call onReady callback when load finish.

Parameters:

  • offset Number

    The offset where sound start.

  • loop Number

    The number of loop where sound played.

  • volume Number

    The volume of sound.

Returns:

Boolean: true if sound begin the loading or false if the sound loading is impossible.

mute

(
  • isMuted
)

Mute or Unmute all sound in this channel.

Parameters:

  • isMuted Boolean

    True for mute or false for unmute.

mute

(
  • value
)

Set current sound volume.

Parameters:

  • value Number

    sound 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 Number

    The 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.