DirectX and Sound

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jovo Mirkovic

    #1

    DirectX and Sound


    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.Direc tX.DirectSound. SecondaryBuffer (fileName, soundDevice)
    If isloop Then
    sound.Play(0, DirectSound.Buf ferPlayFlags.Lo oping)
    Else
    sound.Play(0, DirectSound.Buf ferPlayFlags.De fault)
    End If
    Catch ex As Exception
    MsgBox(ex.Messa ge)
    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

    *** Sent via Developersdex http://www.developersdex.com ***
  • Sid Price

    #2
    Re: DirectX and Sound

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

    DSBCAPS_GLOBALF OCUS 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_WRITEPRIM ARY flag for its
    cooperative level. In this case, the global sounds from other applications
    will not be audible.


    "Jovo Mirkovic" <nospam@sezampr o.yuwrote in message
    news:upzB%235k4 GHA.1248@TK2MSF TNGP03.phx.gbl. ..
    >
    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.Direc tX.DirectSound. SecondaryBuffer (fileName, soundDevice)
    If isloop Then
    sound.Play(0, DirectSound.Buf ferPlayFlags.Lo oping)
    Else
    sound.Play(0, DirectSound.Buf ferPlayFlags.De fault)
    End If
    Catch ex As Exception
    MsgBox(ex.Messa ge)
    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
    >
    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    Working...