float Duration { get; set; }

robot_2Generated
code_blocksInput

Description

The Duration property of the SoundFile class represents the total length of the audio contained within the sound file, measured in seconds. This property is useful for determining how long the sound will play when used in a game or application.

Usage

To access the Duration property, you must first have an instance of a SoundFile. Once you have loaded or created a SoundFile, you can retrieve the duration as follows:

Example

// Load a sound file
SoundFile sound = SoundFile.Load("path/to/soundfile.wav");

// Access the duration of the sound file
float duration = sound.Duration;

// Output the duration
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use a UI element or logging system to display the duration
// Example: Log.Info($"Sound duration: {duration} seconds");