Bagikan melalui


SoundEffect.Play Method

Plays a sound.

Overload List

Name Description
SoundEffect.Play () Plays a sound.
SoundEffect.Play (Single, Single, Single) Plays a sound based on specified volume, pitch, and panning.

Remarks

Play will return 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 call 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
Enable XNA Framework Events in Windows Phone Applications

Reference

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