How To Play Midi's?

Simcoder

Well-known member
Joined
Apr 18, 2003
Messages
124
Location
Texas
Im having problems getting MIDIs to play. However my wavs play fine. Here is my code
------------------------------------------------------------------------------
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Integer) As Long
Const SND_SYNC As Integer = &H0
Const SND_ASYNC As Integer = &H1
Const SND_NODEFAULT As Integer = &H2
Const SND_LOOP As Integer = &H8
Const SND_NOSTOP As Integer = &H10
Dim SoundName As String, wFlags As Integer, x As String



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SoundName = "C:\Gamesound2.wav"
wFlags = SND_ASYNC Or SND_NODEFAULT Or SND_LOOP
x = sndPlaySound(SoundName, wFlags)


----------------------------------------------------------------------------------
I typed the midi as the extension for my midi files but it still doesnt work. Any help would be much appreciated. Thanx
 
Goto my website and in the VB.Net examples section, download my music module. It will play most music files, including midi music. I converted it from my vb6.0 version so there still could be a bug or 2 in it but, for the most part is it stable.

Thine link to website

Vb.Net examples section.


Jason
 
How to play sounds

Simcoder,

I have been looking for a way to play .WAV sounds. I copied your code fragment, and it worked nicely. Thank you.

My question is this:

How did you know how to invoke PlaySound from VB? The documentation of the Declare keyword describes how to get to the functions in the DLLs, but there is no documentation of PlaySound that is useful to a VB programmer. (For example, I cannot find the definitions of the flag bits).

I guess my general question is:

How does a VB programmer learn about the functions embedded in the DLLs?
 
Thanks, Squirm.

I should have thought of the VB6 docs.

Ill keep my editorial opinion of the quality of the .NET documnetation to myself.

Cheers,

rws
 
Back
Top