How to release an mp3 from DX.Audio class?

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

I'm using DirectX to play mp3 files.

Private WithEvents Player As Audio = Nothing
Player = New Audio(Song, False)
Player.Play()
'.......
Player.StopWhenReady()
'.......
Player = Nothing

If I try to do anything to the file afterwards, I get an exception saying
the file is being used by another process. Even when i've loaded another
song. How can I release the file when i'm done playing it so that I can
rename it, or update it?



Thanks.
 
I'm using DirectX to play mp3 files.

Private WithEvents Player As Audio = Nothing
Player = New Audio(Song, False)
Player.Play()
'.......
Player.StopWhenReady()
'.......
Player = Nothing

If I try to do anything to the file afterwards, I get an exception saying
the file is being used by another process. Even when i've loaded another
song. How can I release the file when i'm done playing it so that I can
rename it, or update it?

According to the documentation I found on MSDN, the DirectX "Audio"
class implements IDisposable. This means you should call the Dispose()
method on this object when you are done with it:

Player = New Audio(Song, False)
Try
Player.Play()
...
Player.StopWhenReady()
Finally
Player.Dispose()
End Try
 
Patrick Steele said:
According to the documentation I found on MSDN, the DirectX "Audio"
class implements IDisposable. This means you should call the Dispose()
method on this object when you are done with it:

Player = New Audio(Song, False)
Try
Player.Play()
...
Player.StopWhenReady()
Finally
Player.Dispose()
End Try

.... or use a 'Using' block (VB 2005).
 
Back
Top