Share via


Buffer.Stop() Method (Microsoft.DirectX.DirectSound)

Causes the sound buffer to stop playing.

Definition

Visual Basic Public Sub Stop()
C# public void Stop();
C++ public:
void Stop();
JScript public function Stop();

Remarks

For secondary sound buffers, Buffer.Stop sets the play cursor to the sample that follows the last sample played. This means that when the Buffer.Play method is next called on the buffer, it will continue playing where it left off.

For the primary buffer, if an application has the CooperativeLevel.WritePrimary level, this method will stop the buffer and reset the play cursor to 0 (the beginning of the buffer). This is necessary because the primary buffers on most sound cards can play only from the beginning of the buffer.

However, if Buffer.Stop is called on a primary buffer and the application has a cooperative level other than CooperativeLevel.WritePrimary, this method simply reverses the effects of Buffer.Play. It configures the primary buffer to stop if no secondary buffers are playing. If other buffers are playing in this or other applications, the primary buffer will not actually stop until they are stopped. This method is useful because playing the primary buffer consumes processing overhead even if the buffer is playing sound data with the amplitude of 0 decibels.

Exceptions

PriorityLevelNeededException

A cooperative level of Priority or higher is required.

Applies To

SecondaryBuffer