Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to play midi files for my game
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
RaLz




PostPosted: Thu Jun 10, 2004 4:59 pm   Post subject: How to play midi files for my game

how do i do this i need to know how and quickly!!!!
Sponsor
Sponsor
Sponsor
sponsor
Brightguy




PostPosted: Thu Jun 10, 2004 9:40 pm   Post subject: Re: How to play midi files for my game

Well there are two ways that I know of...
Using mciSendString, a list of commands can be found here.
code:
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private lngMciErr As Long

Private Sub Form_Load()
    lngMciErr = mciSendString("open FILENAME type sequencer alias mid1", 0&, 0&, 0&)
    lngMciErr = mciSendString("play mid1", 0&, 0, 0)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    lngMciErr = mciSendString("close mid1", 0&, 0&, 0&)
End Sub

Or you can just use the Microsoft Multimedia Control - add it to your project through the menu Project > Components...
code:
Private Sub Form_Load()
    MMControl1.Filename = FILENAME
    MMControl1.Command = "Open"
    MMControl1.Command = "Play"
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MMControl1.Command = "Close"
End Sub
You can set MMControl1.Visible = False if you don't want to see the control on the form.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: