Home Reference Source
public class | source

Sounds

You can directly use an instance of this class. sounds

A class containing multiple Sound instances

Constructor Summary

Public Constructor
public

Create an instance of Sounds

Method Summary

Public Methods
public

add(name: String, audio: Audio | String): Sound

Adds a Sound instance to the Sounds

public

Returns a new instance of Sounds

public

enable(enable: Boolean)

Sets the Sounds class to enabled or disabled

public

get(name: String): Sound

Returns a specific Sound instance

public

Initializes the Sounds class.

public

mute(mute: Boolean)

Sets the Sounds class to muted or unmuted

public

remove(name: String)

Remove a Sound instance from the Sounds

Public Constructors

public constructor() source

Create an instance of Sounds

Public Methods

public add(name: String, audio: Audio | String): Sound source

Adds a Sound instance to the Sounds

Params:

NameTypeAttributeDescription
name String

An identifer to represent the Audio added

audio Audio | String

An Audio instance or an url to an audio file

Return:

Sound

Returns the Sound instance

public create(): Sounds source

Returns a new instance of Sounds

Return:

Sounds

The newly created Sounds instance

public enable(enable: Boolean) source

Sets the Sounds class to enabled or disabled

Params:

NameTypeAttributeDescription
enable Boolean

If true the Sound instances will be enabled

public get(name: String): Sound source

Returns a specific Sound instance

Params:

NameTypeAttributeDescription
name String

The Sound identifier

Return:

Sound

The Sound which is represented by the identifier

public init(): Promise source

Initializes the Sounds class. This is needed to enable Audio on some devices

Return:

Promise

The promise is resolved once audio is available

public mute(mute: Boolean) source

Sets the Sounds class to muted or unmuted

Params:

NameTypeAttributeDescription
mute Boolean

If true the Sound instances will be muted

public remove(name: String) source

Remove a Sound instance from the Sounds

Params:

NameTypeAttributeDescription
name String

An identifer to represent the Audio to be removed