I have a command button called cmdplay and I want it to play a midi file when I click on it.
How can I do this and what would I put in cmdStop to stop it from playing?
Thanks
Printable View
I have a command button called cmdplay and I want it to play a midi file when I click on it.
How can I do this and what would I put in cmdStop to stop it from playing?
Thanks
use the windows media player plugin thingy.
its a COMPONENT marked Windows Media Player.
say the object is called WMA1.
WMA1.Open "Path_of_file" opens a file.
WMA1.Play plays the opened file.
WMA1.Stop stops it.
Hope that helps.
If you need pure code.. then this would do.. it is also sure to work on any PC (even without the Media Player Component).. no extra controls to be included
Thanksforreading:)Code:'API Declarations
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" ( _
ByVal lpszLongPath As String, ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Private Sub StartMIDI()
midiPath = Space$(128)
GetShortPathName App.Path & "\song.mid", midiPath, 128
'to play
J = InStr(midiPath, Chr$(0))
If J > 0 Then midiPath = Left$(midiPath, J - 1)
mciSendString "open " & LCase$(midiPath) & " alias myfile type sequencer", 0, 0, 0
mciSendString "play myfile", 0, 0, 0
End Sub
Privats Sub StopMIDI()
mciSendString "stop myfile", 0, 0, 0
mciSendString "close myfile", 0, 0, 0
End Sub
---
'Code improved by vBulletin Tool