Skip to content

Latest commit

 

History

History
81 lines (45 loc) · 1.59 KB

File metadata and controls

81 lines (45 loc) · 1.59 KB

Sound

Manages loading and playback of an audio file.


Constructor

new Sound(audioManager, src, label, onReady);

Arguments

  • audioManagerAudioManager The audio manager that will parent this Sound.
  • srcstring The source of the audio.
  • labelstring The unique label to identify this sound.
  • onReadyfunction An optional method to call when the audio file is ready to play. Passed the sound object.

Methods

get playbackRate

Get the audio's playback rate.

set playbackRate(value)

Set the audio's playback rate.

get volume()

Get the volume of playback.

set volume(value)

Set the volume of playback.

Arguments

  • valuenumber The volume level to set. Must be between 0 and 1.

get playing()

Get whether the audio is playing.

get muted()

Get the mute state of the audio.

get loop()

Get the loop value of the audio element.

set loop(value)

Set the loop value of the audio element.

Arguments

  • valueboolean The loop state to set.

mute()

Mute the audio without stopping playback.

play(config)

Begin audio playback.

Arguments

  • configObject Playback configuration data.
    • allowConcurrentPlaybackboolean Whether to allow the sound to be played, even if it is already playing.
    • volumenumber Optionally overwrite the current volume level before playing.
    • loopboolean Whether to loop audio playback.

stop()

Stop audio playback.