Diablicolic Posted August 21, 2003 Posted August 21, 2003 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: Quote "Reality is fake, Dreams are for real"
*Experts* mutant Posted August 21, 2003 *Experts* Posted August 21, 2003 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. Quote
*Experts* Nerseus Posted August 21, 2003 *Experts* Posted August 21, 2003 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 Quote "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
Diablicolic Posted August 21, 2003 Author Posted August 21, 2003 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. :) Quote "Reality is fake, Dreams are for real"
*Experts* mutant Posted August 21, 2003 *Experts* Posted August 21, 2003 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. :) Quote
Diablicolic Posted August 22, 2003 Author Posted August 22, 2003 '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)? :( Quote "Reality is fake, Dreams are for real"
AndreRyan Posted August 22, 2003 Posted August 22, 2003 '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 Quote .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?
Diablicolic Posted August 23, 2003 Author Posted August 23, 2003 Thank you Andre :) Quote "Reality is fake, Dreams are for real"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.