Skip to content

Get Sansar

Script API

PlayHandle

Where: Client
More page actions

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

The PlayHandle represents audio play handles.

public class PlayHandle : Sansar.Script.InstanceInterface, IDisposable

Members at a glance

KindMembers
MethodsDispose · Finalize · GetLoudness · GetPitchShift · GetRemainingSeconds · GetStatus · IsPlaying · OnFinished · SetLoudness · SetPitchShift · Stop

Methods

Dispose

public void Dispose()

Releases resources held by this instance.

Finalize

void Finalize()
Remarks

Ensures that this instance has been Disposed.

GetLoudness

public float GetLoudness()

Retrieves the loudness for this PlayHandle.

Returns: float — The loudness (in dB).

Remarks

This synchronous method returns the broadcasted loudness. It does not wait to hear back from clients.

GetPitchShift

public float GetPitchShift()

Retrieves the relative pitch for this PlayHandle.

Returns: float — The relative pitch.

Remarks

This synchronous method returns the broadcasted pitch. It does not wait to hear back from clients.

GetRemainingSeconds

public float GetRemainingSeconds()

Returns the number of seconds remaining.

Returns: float — The number of seconds remaining. (0 if done playing, -1 if looped)

GetStatus

public PlayStatus GetStatus()

Returns the current PlayStatus.

Returns: PlayStatus — The current PlayStatus.

IsPlaying

public bool IsPlaying()

Returns whether the sound is currently playing.

Returns: bool — true if currently playing

OnFinished

public void OnFinished(Action handler)

Triggers action when this sound is finished playing. Doesn’t trigger if stopped or looping.

ParameterTypeDescription
handlerActionAction to be called when the sound finishes playing.

SetLoudness

public void SetLoudness(float loudness)

Sets the loudness for this PlayHandle.

ParameterTypeDescription
loudnessfloatThe loudness (in dB).
Remarks

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.

Deprecated
[System.Obsolete("Deprecated. Use the Action<> overload", false)] public ulong SetLoudness(     float loudness,     Sansar.Script.ScriptBase.OperationComplete handler )

Sets the loudness for this PlayHandle.

ParameterTypeDescription
loudnessfloatThe loudness (in dB).
handlerSansar.Script.ScriptBase.OperationCompleteHandler to be called when the event completes.

Returns: ulong — The return value is an internal event id.

Remarks

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.

public void SetLoudness(     float loudness,     Action<Sansar.Script.OperationCompleteEvent> handler )

Sets the loudness for this PlayHandle.

ParameterTypeDescription
loudnessfloatThe loudness (in dB).
handlerAction<Sansar.Script.OperationCompleteEvent>Handler to be called when the event completes.
Remarks

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.

SetPitchShift

public void SetPitchShift(float pitch)

Sets the relative pitch for this PlayHandle.

ParameterTypeDescription
pitchfloatThe relative pitch in semitones. (default = 0)
Remarks

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.

Deprecated
[System.Obsolete("Deprecated. Use the Action<> overload", false)] public ulong SetPitchShift(     float pitch,     Sansar.Script.ScriptBase.OperationComplete handler )

Sets the relative pitch for this PlayHandle.

ParameterTypeDescription
pitchfloatThe relative pitch in semitones. (default = 0)
handlerSansar.Script.ScriptBase.OperationCompleteHandler to be called when the event completes.

Returns: ulong — The return value is an internal event id.

Remarks

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.

public void SetPitchShift(     float pitch,     Action<Sansar.Script.OperationCompleteEvent> handler )

Sets the relative pitch for this PlayHandle.

ParameterTypeDescription
pitchfloatThe relative pitch in semitones. (default = 0)
handlerAction<Sansar.Script.OperationCompleteEvent>Handler to be called when the event completes.
Remarks

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.

Stop

public void Stop()

Stops the sound on this PlayHandle.

Remarks

This asynchronous method queues the write then returns.

Deprecated
[System.Obsolete("Deprecated. Use the Action<> overload", false)] public ulong Stop(Sansar.Script.ScriptBase.OperationComplete handler)

Stops the sound on this PlayHandle.

ParameterTypeDescription
handlerSansar.Script.ScriptBase.OperationCompleteHandler to be called when the event completes.

Returns: ulong — The return value is an internal event id.

Remarks

This asynchronous method queues the write then returns.

public void Stop(Action<Sansar.Script.OperationCompleteEvent> handler)

Stops the sound on this PlayHandle.

ParameterTypeDescription
handlerAction<Sansar.Script.OperationCompleteEvent>Handler to be called when the event completes.
Remarks

This asynchronous method queues the write then returns.

public void Stop(bool fadeout)

Stops the sound on this PlayHandle.

ParameterTypeDescription
fadeoutboolWill fade out if true.
Remarks

This asynchronous method queues the write then returns.

Deprecated
[System.Obsolete("Deprecated. Use the Action<> overload", false)] public ulong Stop(     bool fadeout,     Sansar.Script.ScriptBase.OperationComplete handler )

Stops the sound on this PlayHandle.

ParameterTypeDescription
fadeoutboolWill fade out if true.
handlerSansar.Script.ScriptBase.OperationCompleteHandler to be called when the event completes.

Returns: ulong — The return value is an internal event id.

Remarks

This asynchronous method queues the write then returns.

public void Stop(     bool fadeout,     Action<Sansar.Script.OperationCompleteEvent> handler )

Stops the sound on this PlayHandle.

ParameterTypeDescription
fadeoutboolWill fade out if true.
handlerAction<Sansar.Script.OperationCompleteEvent>Handler to be called when the event completes.
Remarks

This asynchronous method queues the write then returns.

Used in examples

Generated from the Sansar 47.10.0 client ScriptApi snapshot.