DirectX SDK |
The DirectSoundBuffer.Play method causes the sound buffer to play from the current position.
object.Play(flags As CONST_DSBPLAYFLAGS)
If the method fails, an error is raised and Err.Number may be set to one of the following error codes:
DSERR_BUFFERLOST |
DSERR_INVALIDCALL |
DSERR_INVALIDPARAM |
DSERR_PRIOLEVELNEEDED |
This method will cause a secondary sound buffer to be mixed into the primary buffer and sent to the sound device. If this is the first buffer to play, it will implicitly create a primary buffer and start playing that buffer; the application need not explicitly direct the primary buffer to play.
If the buffer specified in the method is already playing, the call to the method will succeed and the buffer will continue to play. However, the flags defined in the most recent call supersede flags defined in previous calls.
Primary buffers must be played with the DSBPLAY_LOOPING flag set.
This method will cause primary sound buffers to start playing to the sound device. If the application is set to the DSSCL_WRITEPRIMARY cooperative level, this will cause the audio data in the primary buffer to be sent to the sound device. However, if the application is set to any other cooperative level, this method will ensure that the primary buffer is playing even when no secondary buffers are playing; in that case, silence will be played. This can reduce processing overhead when sounds are started and stopped in sequence, because the primary buffer will be playing continuously rather than stopping and starting between secondary buffers.
Note Before this method can be called on any sound buffer, the application should call the DirectSound.SetCooperativeLevel method and specify a cooperative level, typically DSSCL_NORMAL. If DirectSound.SetCooperativeLevel has not been called, the DirectSoundBuffer.Play method returns with DS_OK, but no sound will be produced until DirectSound.SetCooperativeLevel is called.