Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stopping _SNDPLAYCOPY ?Possible?
#8
I haven't tested this code, but wouldn't something like this work?

Code: (Select All)
ReDim HandleCache(20) As Long


Sub PlaySound (handle As Long)
    For i = 1 to UBOUND(HandleCache)
        If HandleCache(i) <= 0 _OrElse Not _SndPlaying(HandleCache(i)) Then
            _SndClose HandleCache(i)
            HandleCache(i) = _SndCopy(handle)
            _SndPlay HandleCache(i)
           
            Exit Sub
        End If
    Next

    ReDim HandleCache(UBOUND(HandleCache + 1)) As Long

    HandleCache(UBOUND(HandleCache)) = _SndCopy(handle)
    _SndPlay HandleCache(UBOUND(HandleCache))
End Sub

Sub KillSounds ()
    For i = 1 to Ubound(HandleCache)
        If HandleCache(i) > 0 Then
            _SndClose HandleCache(i)
            HandleCache(i) = -1
        End If
    Next
End Sub

And then you just replace the `_SndPlayCopy` calls with `PlaySound` calls and call `KillSounds` when you're done. It's not super pretty but it doesn't seem all that bad overall.
Reply


Messages In This Thread
RE: Stopping _SNDPLAYCOPY ?Possible? - by a740g - 08-07-2024, 02:48 PM
RE: Stopping _SNDPLAYCOPY ?Possible? - by Pete - 08-07-2024, 03:44 PM
RE: Stopping _SNDPLAYCOPY ?Possible? - by DSMan195276 - 08-07-2024, 05:36 PM
RE: Stopping _SNDPLAYCOPY ?Possible? - by Pete - 08-07-2024, 11:16 PM



Users browsing this thread: 1 Guest(s)