Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Me no can dispose the audio stuff:

 

'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:

"Reality is fake, Dreams are for real"
  • *Experts*
Posted

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.

  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

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

 

Neither does:

 

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. :)

"Reality is fake, Dreams are for real"
  • *Experts*
Posted

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.

:)

Posted

'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)?

 

 

 

:(

"Reality is fake, Dreams are for real"
Posted

'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

'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

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...