AudioPlay.js
AudioPlay
AudioPlay is a class that plays audio files.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
key | string | The key of the sprite. |
loop | boolean | If the audio file should loop. |
paused | boolean | If the audio file is paused. |
volume | number | The volume of the audio file. |
muted | boolean | If the audio file should be muted. |
delay | number | The delay of the audio file. |
- AudioPlay
- .this.name :
string
- .this.paused :
boolean
- .this.volume :
number
- .this.loop :
boolean
- .this.muted :
boolean
- .this.delay :
number
- .this.loopDelay :
number
- .play() ⇒
AudioPlay
- .playOnce() ⇒
AudioPlay
- .pause() ⇒
AudioPlay
- .resume() ⇒
AudioPlay
- .stop() ⇒
AudioPlay
- .setVolume(volume) ⇒
AudioPlay
- .setLoop(loop) ⇒
AudioPlay
- .setMuted(delay) ⇒
AudioPlay
- .setDelay(delay) ⇒
AudioPlay
- .isEnded() ⇒
boolean
- .getDuration() ⇒
number
- .this.name :
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
Param | Type | Description |
---|---|---|
volume | number | 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
Param | Type | Description |
---|---|---|
loop | boolean | 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
Param | Type | Description |
---|---|---|
delay | number | 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
Param | Type | Description |
---|---|---|
delay | number | 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();