Bagikan melalui


DynamicSoundEffectInstance.Play Method

Begins or resumes audio playback.

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

Syntax

public override void Play ()

Exceptions

Exception type Condition
ObjectDisposedException Exception thrown if Play is called after DynamicSoundEffectInstance is disposed.
InstancePlayLimitException Exception thrown when the amount of concurrent DynamicSoundEffectInstance sounds playing exceeds the platform limit.
InvalidOperationException Exception thrown when playback of the DynamicSoundEffectInstance fails.

Remarks

Play has no effect if the DynamicSoundEffectInstance object is playing currently.

Each platform has limits on the number of sounds playing simultaneously. A InstancePlayLimitException exception is thrown if this limit is exceeded. The following table shows the limits for simultaneous playing sounds based on platform.

Platform Number of sounds that can play simultaneously
Windows Phone 64
Xbox 360 300
Windows No limit

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

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

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone