PDA

Click to See Complete Forum and Search --> : DIRECT MUSIC--- STOPPING A MIDI


wengang
Apr 20th, 2000, 07:43 PM
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?

KENNNY
Apr 21st, 2000, 02:18 AM
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).

wengang
Apr 21st, 2000, 09:12 AM
Sorry Kenny, but one last question.....


which is the segment to stop:
objSeg
strMIDI
?

I haven't gottten either one to work..

KENNNY
Apr 21st, 2000, 07:41 PM
the segment object!

eg

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

that should work.

wengang
Apr 21st, 2000, 11:40 PM
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.