Microsoft SDK for Java

play

This method of the DirectSoundBuffer Class causes the sound buffer to play from the current position.

Syntax

public void play(int flags);

Parameters

flags One value of DSBPLAY_ type, specifying how to play the buffer.

Remarks

For secondary sound buffers, this method will cause the buffer to be mixed into the primary buffer and output 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 does not need to 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 that define playback characteristics are superseded by the flags defined in the most recent call.

Primary buffers must be played with the DSBPLAY_LOOPING flag set.

For primary sound buffers, this method will cause them 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 output 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, since 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 must call the setCooperativeLevel method and specify a cooperative level, typically DSSCL_NORMAL. If setCooperativeLevel has not been called, the play method carries out no action.

See Also

com.ms.directX.DirectSound

© 1999 Microsoft Corporation. All rights reserved. Terms of use.