SoundEffect.Play Method (Single, Single, Single, Boolean)

Creates a new SoundEffectInstance and plays it using the specified volume, pitch, panning, and loop control.

Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public SoundEffectInstance Play (
         float volume,
         float pitch,
         float pan,
         bool loop
)

Parameters

  • volume
    Volume, ranging from 0.0f (silence) to 1.0f (full volume). 1.0f is full volume relative to SoundEffect.MasterVolume.
  • pitch
    Pitch adjustment, ranging from -1.0f (down one octave) to 1.0f (up one octave). 0.0f is unity (normal) pitch.
  • pan
    Panning, ranging from -1.0f (full left) to 1.0f (full right). 0.0f is centered.
  • loop
    Whether to loop the sound indefinitely, until stopped by the application. Specify true to continuously loop the sound's loop region, or false to play the entire sound just once.

Return Value

A new, playing, SoundEffectInstance.

Remarks

If loop is true, the sound's loop region will play continuously until stopped with a call to Stop or Pause on the returned SoundEffectInstance. The loop region as authored in the sound file is used. If the sound file has no loop region, the entire sound is looped.

See Also

Reference

SoundEffect Class
SoundEffect Members
Microsoft.Xna.Framework.Audio Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista, Zune