Results 1 to 3 of 3

Thread: Playing MIDI files

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    55

    Smile

    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
    Beres

  2. #2
    New Member
    Join Date
    Mar 2001
    Posts
    11

    WMA

    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.

  3. #3
    Guest
    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

    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
    Thanksforreading:)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width