1 Attachment(s)
[RESOLVED] Using Direct Sound
Hello. I am trying to use direct sound to play a wav file, so I may animate a picture box while the wav file is playing. I have made a device object and a secondary buffer object and when I run the program I get an error message(see attached image), but after I click continue, the wav file plays and it plays every time I click the play wav button. I am using a test project to work out the bugs before I implement the direct sound in my other project. Below is the the code I am using. Can someone tell me what I am doing wrong? I would greatly appreciate it. The code needs a form named form1, and a button named xPlayButton.
Code:
Imports Microsoft.DirectX.DirectSound
Public Class Form1
Private Sub xPlayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xPlayButton.Click
Dim sDevice As New Device
sDevice.SetCooperativeLevel(Me, CooperativeLevel.Normal)
Dim secBuffer As New SecondaryBuffer(My.Resources.b, My.Resources.b.Length, sDevice)
secBuffer.Play(0, BufferPlayFlags.Default)
End Sub
End Class