PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

TimeLength

Sound

double

The length of the Sound in seconds. If the Sound is not loaded, this value will be 0.

This property is often used in conjunction with Sound/PlaybackSpeed to adjust the speed of a sound so it lasts for a specific duration (see examples). When Sound/PlaybackSpeed is equal to 1, the sound will take TimeLength seconds to complete.


Code Samples


Play a Sound for a Specific Duration

This code sample includes a simple function that uses Sound.TimeLength and Sound.PlaybackSpeed to play a sound that’ll take the given duration to complete. It achieves this by setting the PlaybackSpeed of the sound to be equal to the TimeLength of the sound divided by the desired duration.

Note that as TimeLength is equal to 0 when the sound has not loaded, the function will yield whilst it loads the sound.