Results 1 to 5 of 5

Thread: DIRECT MUSIC--- STOPPING A MIDI

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Hey guys,
    I copied this code from MS's website to play a midi in the background:

    Public gObjDX As New DirectX7
    Public gObjDMLoader As DirectMusicLoader
    Public gObjDMPerformance As DirectMusicPerformance
    Dim objSegState As DirectMusicSegmentState
    Dim objSeg As DirectMusicSegment

    Set gObjDMLoader = gObjDX.DirectMusicLoaderCreate
    Set gObjDMPerformance = gObjDX.DirectMusicPerformanceCreate
    Call gObjDMPerformance.Init(Nothing, hWnd)
    Call gObjDMPerformance.SetPort(-1, 1)
    strMIDI = CurDir & "\Directory\music.mid"
    Set objSeg = gObjDMLoader.LoadSegment(strMIDI)
    Call gObjDMPerformance.SetMasterAutoDownload(True)
    Call objSeg.Download(gObjDMPerformance)
    Call gObjDMPerformance.PlaySegment(objSeg, 0, 0)
    'Set objSegState = gObjDMPerformance.PlaySegment(gObjPrimarySeg, 0, 0)

    SO what is the command to stop the music? Does anybody know this one?

  2. #2
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    indeed:

    DirectMusicPerformance.Stop

    parameters:

    segment - the segment to stop
    segmentstate - the segment state of the above segment (you dont need this)
    time - when to stop, set to 0 for immediately
    flags - set to 0 probably (the other values are a bit obscure, you wont need them).
    buzzwords are the language of fools

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Segment

    Sorry Kenny, but one last question.....


    which is the segment to stop:
    objSeg
    strMIDI
    ?

    I haven't gottten either one to work..



  4. #4
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    the segment object!

    eg

    Call DmPer.Stop(segment, nothing, 0, 0)

    that should work.

    buzzwords are the language of fools

  5. #5

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    got it, thanks

    Right.

    I got that this afternoon.

    I guess I should have spent more time trying to figure it out myself before posting


    The part I was missing was the 2nd one (nothing). So my game is pretty much complete.

    Thanks again.


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