I cannot dispose audio from DirectX

Diablicolic

Well-known member
Joined
Jul 28, 2003
Messages
168
Location
Your Neighbor
Me no can dispose the audio stuff:

[VB]
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
[/VB]

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? Thats 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 doesnt work either...

Neither does:

[VB]
Background = Background.Dispose()[/VB]

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

And yes Im 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.
:)
 
[VB]
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
[/VB]

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



:(
 
Code:
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 cant release memory in use anyway.

The error box image you posted says the function "Audio.Play()" caused the error meaning that you Disposed or hadnt created the object. You should see if youre 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
Code:
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