I cannot dispose audio from DirectX

Diablicolic

Centurion
Joined
Jul 28, 2003
Messages
167
Location
Your Neighbor
Me no can dispose the audio stuff:

Visual Basic:
'The music is currently playing

Private Sub JustbtnNeww_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        System.Threading.Thread.Sleep(2000)

        'Hopefully stops the sounds from working <( )>
        Background.Dispose()
        HighlightSound.Dispose()
        SelectSound.Dispose()
End Sub

But I get this error:
 

Attachments

There error says that there is no instance, do you currently have an instance of the object that causes the error, the the sound playing when you call that code?
Also you say you want to stop the sound, Stop() method would work.
 
Are you using Dispose as a way to stop the sound from playing? That's a .NET method for disposing of resources used by an object, no the same as a Stop method (or whatever DirectX is using).

-Ner
 
Well I have the Background.Stop() before the Background.Dispose(), but that doesn't work either...

Neither does:

Visual Basic:
Background = Background.Dispose()

And the error I get is that the Background.Dispose does not produce a value.

And yes I'm using directx audioandvideoplayback. :)
 
You will get that error on the line you showed, Dispose method doesnt return anything so you cant assign the result of it to anyting because it simply doesnt return a result.
:)
 
Visual Basic:
'The music is currently playing

Private Sub JustbtnNeww_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        System.Threading.Thread.Sleep(2000)

        'Hopefully stops the sounds from working <( )>
        Background.Stop()
        HighlightSound.Stop()
        SelectSound.Stop()
        Background.Dispose()
        HighlightSound.Dispose()
        SelectSound.Dispose()
End Sub

Now why do I still get that error (the one that I posted on the top as an attachment)?



:(
 
Visual Basic:
'The music is currently playing

Private Sub JustbtnNeww_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        System.Threading.Thread.Sleep(2000) 'What exactly is this for?

        'Hopefully stops the sounds from working <( )>
        If Not BackGround Is Nothing Then Background.Dispose()
        If Not HighlightSound Is Nothing Then HighlightSound.Dispose()
        If Not SelectSound Is Nothing Then SelectSound.Dispose()
End Sub
This should destroy the objects only if they exist. Dispose stops the sound as well as destroying since you can't release memory in use anyway.

The error box image you posted says the function "Audio.Play()" caused the error meaning that you Disposed or hadn't created the object. You should see if you're attempting to play a sound again after its been disposed.

If the code you posted is a Stop(Reset Sound) button not Exit(Destroy Sound) then
Visual Basic:
'The music is currently playing

Private Sub JustbtnNeww_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        System.Threading.Thread.Sleep(2000) 'What exactly is this for?

        'Hopefully stops the sounds from working <( )>
        If Not BackGround Is Nothing Then Background.Stop()
        If Not HighlightSound Is Nothing Then HighlightSound.Stop()
        If Not SelectSound Is Nothing Then SelectSound.Stop()
End Sub
 
Back
Top