DirectX and Sound

J

Jovo Mirkovic

Hi,

We are working on some application in DirectX, and we are using
DirectSound, like this

Public Sub playSound(ByVal isloop As Boolean, ByVal fileName As
String)
Try
stopSound()
sound = New
Microsoft.DirectX.DirectSound.SecondaryBuffer(fileName, soundDevice)
If isloop Then
sound.Play(0, DirectSound.BufferPlayFlags.Looping)
Else
sound.Play(0, DirectSound.BufferPlayFlags.Default)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

and that is OK, but we have problem, because sonund stop every time when
form lost focus... :(

Any idea?

Thanks,

Jovo
 
S

Sid Price

You need to set the following flag in the buffer descriptor:

DSBCAPS_GLOBALFOCUS The buffer is a global sound buffer. With this
flag set, an application using DirectSound can continue to play its buffers
if the user switches focus to another application, even if the new
application uses DirectSound. The one exception is if you switch focus to a
DirectSound application that uses the DSSCL_WRITEPRIMARY flag for its
cooperative level. In this case, the global sounds from other applications
will not be audible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top