SoundEffect.Play Method ()
Plays a sound.
Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public bool Play ()
Return Value
true if the sound is playing back successfully; otherwise, false.
Remarks
Play returns false if too many sounds already are playing.
To loop a sound or apply 3D effects, call CreateInstance instead of Play, and SoundEffectInstance.Play.
Sounds play in a "fire and forget" fashion with Play; therefore, the lifetime of these sounds is managed by the framework. These sounds will play once, and then stop. They cannot be looped or 3D positioned. To loop a sound or apply 3D effects, call CreateInstance instead of Play, or SoundEffectInstance.Play.
Silverlight applications must ensure that FrameworkDispatcher.Update is called regularly in order for "fire and forget" sounds to work correctly. Play throws an InvalidOperationException if FrameworkDispatcher.Update has not been called at least once before making this call. For more information, see Enable XNA Framework Events in Windows Phone Applications.
See Also
Tasks
Playing a Sound
Looping a Sound
Enable XNA Framework Events in Windows Phone Applications
Reference
SoundEffect Class
SoundEffect Members
Microsoft.Xna.Framework.Audio Namespace
Platforms
Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone