SoundEffect.Play Method (Single, Single, Single)
Plays a sound based on specified volume, pitch, and panning.
Syntax
'Declaration
Public Function Play ( _
volume As Single, _
pitch As Single, _
pan As Single _
) As Boolean
public bool Play (
float volume,
float pitch,
float pan
)
public:
bool Play(
float volume,
float pitch,
float pan
)
Parameters
- volume
Type: Single
Volume, ranging from 0.0f (silence) to 1.0f (full volume). 1.0f is full volume relative to SoundEffect.MasterVolume. - pitch
Type: Single
Pitch adjustment, ranging from -1.0f (down one octave) to 1.0f (up one octave). 0.0f is unity (normal) pitch. - pan
Type: Single
Panning, ranging from -1.0f (full left) to 1.0f (full right). 0.0f is centered.
Return Value
Type: Boolean
true if the sound is playing back successfully; otherwise, false.
Remarks
Play will return false if there 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.
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.
Requirements
Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
See Also
Tasks
Playing a Sound
Enable XNA Framework Events in Windows Phone Applications
Reference
SoundEffect Class
SoundEffect Members
Microsoft.Xna.Framework.Audio Namespace
Platforms
Windows Phone