Skip to content

Get Sansar

Script API

AudioComponent

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

The AudioComponent handles interactions with audio components.

public class AudioComponent : Sansar.Script.InstanceInterface

Members at a glance

KindMembers
FieldsComponentType
PropertiesComponentId · Name
MethodsPlaySoundOnComponent · PlayStreamOnComponent · ToString

Fields

ComponentType

public static readonly ComponentType ComponentType

The AudioComponent.ComponentType of this component

Properties

ComponentId

public Sansar.Script.ComponentId ComponentId { get; }

Retrieves the component id for this AudioComponent.

Value: Sansar.Script.ComponentId — The id.

Name

Added in 33.2.0
public string Name { get; }

This AudioComponent name, as specified in the editor.

Methods

PlaySoundOnComponent

public PlayHandle PlaySoundOnComponent(     SoundResource soundResource,     PlaySettings playSettings )

Play sound on this component (and follow its position).

ParameterTypeDescription
soundResourceSoundResourceThe sound resource to play.
playSettingsPlaySettingsThe play parameters.

Returns: PlayHandle — The play handle for controlling playback.

Remarks

Plays for all agents in this scene. As the component moves, this sound will follow the component’s location.

PlayStreamOnComponent

public PlayHandle PlayStreamOnComponent(     StreamChannel streamChannel,     float loudness )

Play web audio stream on this component (and follow its position).

ParameterTypeDescription
streamChannelStreamChannelChannel of the audio stream to play.
loudnessfloatRelative loudness in dB.

Returns: PlayHandle — The play handle for controlling playback.

Remarks

Plays for all agents in this scene. As the component moves, this stream will follow the component’s location.

ToString

public override string ToString()

A string representation of this object.

Returns: string — A string representation of this object.

Remarks

The format of this string may change between releases.

Used in examples

Generated from the Sansar 47.10.0 client ScriptApi snapshot.