float ElapsedTime { get; set; }

robot_2Generated
code_blocksInput

Description

The ElapsedTime property of the SoundHandle class provides the amount of time, in seconds, that has elapsed since the sound started playing. This property is useful for tracking the duration a sound has been playing, which can be used for timing events or synchronizing actions with the sound.

Usage

To access the ElapsedTime property, you need an instance of the SoundHandle class. This property is read-only and returns a float representing the elapsed time in seconds.

Example

// Assuming 'sound' is an instance of SoundHandle
float timeElapsed = sound.ElapsedTime;

// Use the elapsed time for logic
if (timeElapsed > 5.0f)
{
    // Perform an action after 5 seconds of sound play
    // e.g., stop the sound or trigger an event
    sound.Stop(1.0f); // Stops the sound with a fade out of 1 second
}