AudioVideoPlayback cannot play different files

georgepatotk

Contributor
Joined
Mar 1, 2004
Messages
432
Location
Malaysia
Dear

I am struggling with this problem for few days already. Hope you could help me on this.

I am using AudioVideoPlayback.Audio to play midi files in my application.

For playing the first file, it works great. But when I play the second file, it gives me problem. Anyone can tell me why is this?

Below are the codes:

Variable:
Private WithEvents MusicAdapter1 As Microsoft.DirectX.AudioVideoPlayback.Audio

To play the file midi:
MusicAdapter1 = New Audio(MusicArray(0))
MusicAdapter1.Play()

To play the second file: (this is where problem occured)
MusicAdapter1.Stop()
MusicAdapter1.Dispose()
MusicAdapter1 = Nothing
MusicAdapter1 = New Audio(MusicArray(1))
MusicAdapter1.Play()

I am suspecting on the resource releasing problem. But, I couldn't find anyway to solve it. Please help me on that.
 
I think I am right. After I googling around, I can be very sure that the problem is over the method of dispose.

AudioVideoPlayback.Audio.Dispose doesn't work correctly. Or in other word, it has bug in it's code. Anyone knows the work-around for this bug? I need this urgently, please. Thanks for your kindness..
 
georgepatotk said:
I think I am right. After I googling around, I can be very sure that the problem is over the method of dispose.

AudioVideoPlayback.Audio.Dispose doesn't work correctly. Or in other word, it has bug in it's code. Anyone knows the work-around for this bug? I need this urgently, please. Thanks for your kindness..

Did you take out the Dispose call and it worked? I would guess not.

Also, can you simply do the New call with the same variable (object reference) and then garbage collection would get rid of the previous (now unreferenced) object instance?

I may be wrong about .NET in general on that, and even if I'm not the garbage collection may not be able to clear it out if the Dispose doesn't work. But even if garbage collection doesn't clean up the unreferenced one I think that the new reference should work, unless somehow there is nothing in MusicArray(1). I guess I'm thinking about .NET in general when it comes to this problem.

Anyone else on this topic? :confused:
 
I can be very sure that the dispose didn't work. The garbage collect is working as to clear the unused object. But, it would take some times as to clear it out.

Assume that I am having a mouseover sound (voice of "TIP") and mouseleave(voice of "top"). To implement GC, the sound will take few seconds to be played. Got my meaning?


Code:
when you say it doesn't work correctly - what problems are you experiencing?

The Audio.Dispose is creating a new object instead of dispose the current object. (this is from internet sources, but, I found out the problem but no solution)

Before I foudn out this from Internet, I had already suspect on the same problem. What else you need to know?

-------------------------- what i want ----------------------
I wish to know how to clear the object(audio) by overloads the existing Dispose method. Can anyone let me know on this?
 
On a similar note, has anyone been having OutOfMemoryException's when running a lot of audio/video? I have to manually call GC.Collect() to empty the Virtual Memory. I am undecided if this is a good or bad thing.
 
Back
Top