Description
The Duration
property of the SoundFile
class represents the length of the audio contained within the sound file, measured in seconds. This property provides a straightforward way to determine how long the sound will play when used in your application.
Usage
To access the Duration
property, you must first have an instance of a SoundFile
. This property is read-only and returns a float
value representing the duration in seconds.
Example
// Example of accessing the Duration property
// Load a sound file
SoundFile sound = SoundFile.Load("path/to/soundfile.wav");
// Check if the sound file is loaded
if (sound.IsLoaded)
{
// Get the duration of the sound file
float duration = sound.Duration;
// Output the duration
// Note: Avoid using Console.WriteLine in s&box, use logging or UI elements instead
Log.Info($"Sound duration: {duration} seconds");
}