static SoundHandle PlayFile( SoundFile soundFile, float volume, float pitch, float decibels, float delay )
static SoundHandle PlayFile( SoundFile soundFile, float volume, float pitch, float delay )

robot_2Generated
code_blocksInput

Description

The PlayFile method in the Sandbox.Sound class is used to play a sound file with specified parameters such as volume, pitch, decibels, and delay. This method returns a SoundHandle which can be used to control the playback of the sound.

Note: The use of decibels is marked as obsolete, and it is recommended to adjust the volume using the volume parameter instead.

Usage

To use the PlayFile method, provide the following parameters:

  • soundFile: The SoundFile object representing the sound to be played.
  • volume: A float value representing the volume level of the sound. This should be a value between 0.0 (mute) and 1.0 (full volume).
  • pitch: A float value representing the pitch of the sound. A value of 1.0 represents the normal pitch.
  • decibels: A float value representing the decibel level. This parameter is obsolete and should be avoided.
  • delay: A float value representing the delay in seconds before the sound starts playing.

Example

// Example of using the PlayFile method
SoundFile mySoundFile = new SoundFile("path/to/soundfile.wav");
float volume = 0.8f; // 80% volume
float pitch = 1.0f; // Normal pitch
float decibels = 0.0f; // Obsolete, avoid using
float delay = 0.5f; // Half a second delay

SoundHandle handle = Sound.PlayFile(mySoundFile, volume, pitch, decibels, delay);

// Use the handle to control the sound playback if needed
// handle.Stop(); // Example of stopping the sound