Skip to main content

AudioPlay.js

AudioPlay

AudioPlay is a class that plays audio files.

Kind: global class
Properties

NameTypeDescription
keystring

The key of the sprite.

loopboolean

If the audio file should loop.

pausedboolean

If the audio file is paused.

volumenumber

The volume of the audio file.

mutedboolean

If the audio file should be muted.

delaynumber

The delay of the audio file.

AudioPlay.this.name : string

The source of the audio file.

Kind: static property of AudioPlay
Default: "\"\""

AudioPlay.this.paused : boolean

If the audio file should loop.

Kind: static property of AudioPlay
Default: false

AudioPlay.this.volume : number

The volume on reproducing the audio file.

Kind: static property of AudioPlay
Default: 1

AudioPlay.this.loop : boolean

If the audio should be in loop.

Kind: static property of AudioPlay
Default: false

AudioPlay.this.muted : boolean

If the audio should be muted.

Kind: static property of AudioPlay
Default: false

AudioPlay.this.delay : number

The delay of the audio file.

Kind: static property of AudioPlay
Default: 0

AudioPlay.this.loopDelay : number

The time of the audio file.

Kind: static property of AudioPlay
Default: 0

AudioPlay.play() ⇒ AudioPlay

Plays the audio file.

Kind: static method of AudioPlay
Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.play();

AudioPlay.playOnce() ⇒ AudioPlay

just plays once time the audio file.

Kind: static method of AudioPlay
Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.playOnce();

AudioPlay.pause() ⇒ AudioPlay

Pause the audio file.

Kind: static method of AudioPlay
Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.pause();

AudioPlay.resume() ⇒ AudioPlay

Resume the audio file.

Kind: static method of AudioPlay
Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.resume();

AudioPlay.stop() ⇒ AudioPlay

Stop the audio file.

Kind: static method of AudioPlay
Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.stop();

AudioPlay.setVolume(volume) ⇒ AudioPlay

Set the volume of the audio file.

Kind: static method of AudioPlay

ParamTypeDescription
volumenumber

The volume of the audio file.

Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.setVolume(0.5);

AudioPlay.setLoop(loop) ⇒ AudioPlay

Set loop of the audio file. If the audio file is looping, it will be played again.

Kind: static method of AudioPlay

ParamTypeDescription
loopboolean

If the audio file should be looping.

Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.setLoop(true);

AudioPlay.setMuted(delay) ⇒ AudioPlay

Set the delay of the audio file.

Kind: static method of AudioPlay

ParamTypeDescription
delaynumber

The delay of the audio file.

Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.setDelay(1000);

AudioPlay.setDelay(delay) ⇒ AudioPlay

Set the delay of the audio file.

Kind: static method of AudioPlay

ParamTypeDescription
delaynumber

The delay of the audio file.

Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.setDelay(1000);

AudioPlay.isEnded() ⇒ boolean

Check if the audio file is ended playing.

Kind: static method of AudioPlay
Returns: boolean -

If the audio file is ended playing.


See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended
Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.isEnded();

AudioPlay.getDuration() ⇒ number

Returns the time of the audio file.

Kind: static method of AudioPlay
Returns: number -

The time of the audio file.


Example

const myAudioPlay = new Impacto.GameObjects.AudioPlay("MyAudio");
myAudioPlay.getDuration();