Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Represents a handle to a sound that has been played. The handle is required to control the sound while it is playing (for example, to call stop, setVolume, setPitch, fade, or seekTo). Infinitely-looping sounds (started with loop: -1) stop automatically when the last SoundInstance reference is dropped; retain the handle for as long as the sound should keep playing.
Properties
durationInfo
read-only durationInfo?: SoundDurationInfo;
Gets duration and playback information for this sound.
Type: SoundDurationInfo
Caution
This property is still in pre-release. Its signature may change or it may be removed in future releases.
id
read-only id: string;
Unique identifier of this sound instance.
Type: string
Caution
This property is still in pre-release. Its signature may change or it may be removed in future releases.
recipient
read-only recipient?: Player;
Gets the player this sound was played for.
Type: Player
Caution
This property is still in pre-release. Its signature may change or it may be removed in future releases.
soundEventId
read-only soundEventId: string;
Gets the identifier of the sound event this instance was started with.
Type: string
Caution
This property is still in pre-release. Its signature may change or it may be removed in future releases.
Methods
fade
fade(duration: number, targetVolume: number): void
Fades this sound instance from its current volume to the target volume over the specified duration. To fade in from silence, call setVolume(0.0) first; to fade out, pass a target volume of 0.0.
Parameters
duration: number
- Minimum Bound:
0
Duration of the fade in seconds. Must be non-negative.
- Minimum Bound:
targetVolume: number
- Minimum Bound:
0
Volume to fade to. Must be non-negative.
- Minimum Bound:
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
pause
pause(): void
Pauses this sound.
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
resume
resume(): void
Resumes this sound after a pause.
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
seekTo
seekTo(seconds: number): void
Sets the playback position of this sound instance.
Parameters
seconds: number
- Minimum Bound:
0
Position to seek to in seconds. Must be non-negative.
- Minimum Bound:
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
setPitch
setPitch(pitch: number): void
Sets the pitch of this sound instance.
Parameters
pitch: number
- Bounds: [
0.009999999776482582,10]
Pitch multiplier between 0.01 and 10.0. A value of 1.0 is normal pitch.
- Bounds: [
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
setVolume
setVolume(volume: number): void
Sets the volume of this sound instance.
Parameters
volume: number
- Bounds: [
0,10]
Volume level between 0.0 and 10.0.
- Bounds: [
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
stop
stop(): void
Stops this sound instance from playing.
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.