The PlayHandle represents audio play handles.
public class PlayHandle : Sansar.Script.InstanceInterface, IDisposableMembers at a glance
| Kind | Members |
|---|---|
| Methods | Dispose · 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.
| Parameter | Type | Description |
|---|---|---|
handler | Action | Action to be called when the sound finishes playing. |
SetLoudness
public void SetLoudness(float loudness)Sets the loudness for this PlayHandle.
| Parameter | Type | Description |
|---|---|---|
loudness | float | The 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.
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetLoudness(
float loudness,
Sansar.Script.ScriptBase.OperationComplete handler
)Sets the loudness for this PlayHandle.
| Parameter | Type | Description |
|---|---|---|
loudness | float | The loudness (in dB). |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler 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.
| Parameter | Type | Description |
|---|---|---|
loudness | float | The loudness (in dB). |
handler | Action<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.
| Parameter | Type | Description |
|---|---|---|
pitch | float | The 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.
[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.
| Parameter | Type | Description |
|---|---|---|
pitch | float | The relative pitch in semitones. (default = 0) |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler 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.
| Parameter | Type | Description |
|---|---|---|
pitch | float | The relative pitch in semitones. (default = 0) |
handler | Action<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.
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Stop(Sansar.Script.ScriptBase.OperationComplete handler)Stops the sound on this PlayHandle.
| Parameter | Type | Description |
|---|---|---|
handler | Sansar.Script.ScriptBase.OperationComplete | Handler 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.
| Parameter | Type | Description |
|---|---|---|
handler | Action<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.
| Parameter | Type | Description |
|---|---|---|
fadeout | bool | Will fade out if true. |
Remarks
This asynchronous method queues the write then returns.
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Stop(
bool fadeout,
Sansar.Script.ScriptBase.OperationComplete handler
)Stops the sound on this PlayHandle.
| Parameter | Type | Description |
|---|---|---|
fadeout | bool | Will fade out if true. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler 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.
| Parameter | Type | Description |
|---|---|---|
fadeout | bool | Will fade out if true. |
handler | Action<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.