Results 1 to 2 of 2

Thread: Playing a midi file without interupting the program

  1. #1
    Guest

    Question

    I need some code help for playing a MIDI file without interupting the actual program, it would play in the background, also it needs to have a pause button.

  2. #2
    Guest

    Smile Try this...

    Use the mciSendString API. In the following example, you will need to make a series of CommandButton. It might be a good idea to change the caption to the correct function.

    code for module.

    Code:
    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
    Put this code in a CommandButton
    Code:
    'Opens the file
    mciSendString "open C:\MyMIDI.mid type sequencer alias background", 0, 0, 0
    Put this in another CommandButton
    Code:
    ' Plays the midi
    mciSendString "play background", 0, 0, 0
    Put this code in another CommandButton
    Code:
    'Pauses the midi
    mciSendString "pause background", 0, 0, 0
    Put this code in another CommandButton
    Code:
    'Closes the file
    mciSendString "close background", 0, 0, 0

    Always make sure that you Close the file before exiting the program because it will contiune to play until Windows sends a message for the program to stop. This means that if you exit your App while the music is playing, it will still contiune to play. So to prevent this, aslways close the file when you are done.





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