Create, Compete & Win at Redbrick Connect 2024! 🎉

Audio

This class provides information about properties and methods related to audio.

⚠️

The following properties and methods can only be used on an audio object retrieved using .getAudio().

Example:

getAudio
const audio_obj = WORLD.getObject("audio_object").getAudio();
 
audio_obj.play();
audio_obj.stop();
console.log(audio_obj.isPlaying);

Besides the information below, you can also utilize various properties and methods of THREE.Audio.

Properties

.isPlaying

.isPlaying : Boolean

Returns whether the audio is currently playing.

.hasPlaybackControl

.hasPlaybackControl : Boolean

Specifies whether playback can be controlled using methods like .play(), .pause(), etc. Default is true.

Methods

.getPlaybackRate()

.getPlaybackRate() : Float

Returns the value of the playback rate.

.getVolume()

.getVolume() : Float

Returns the current volume value.

.play()

.play(delay) : this

Starts playback if hasPlaybackControl is true.

.pause()

.pause() : this

Pauses playback if hasPlaybackControl is true.
An audio that is paused will resume playback from the point it was paused when played again.

.setPlaybackRate()

.setPlaybackRate(value : Float) : this

Sets the playback rate if hasPlaybackControl is enabled.

.setVolume()

.setVolume(value : Float) : this

Sets the volume.

.stop()

.stop() : this

Stops playback if hasPlaybackControl is enabled.
An audio that is stopped will start playback from the beginning when played again.