Microsoft DirectX 8.1 (Visual Basic) |
When the Play button is clicked, the following procedure checks the state of the option buttons, loads the appropriate segment if one has not already been loaded in response to an option button selection, and plays the segment as a primary segment on the audiopath created previously.
Private Sub cmdPlay_Click()
If dmSeg Is Nothing Then
If optWave.Value Then LoadSound MediaPath & "\tuta.wav"
If optMid.Value Then LoadSound MediaPath & "\tut.mid"
If optSeg.Value Then LoadSound MediaPath & "\sample.sgt"
End If
Set dmSegState = dmp.PlaySegmentEx(dmSeg, 0, 0, Nothing, dmPath)
End Sub
The procedure obtains a DirectMusicSegmentState8 object, which could be used to retrieve information about the state of the playback. The segment state can also be passed to DirectMusicPerformance8.StopEx to stop just one instance of the segment. This is useful for secondary segments, where multiple instances might be playing at the same time.
Next: Step 7: Stop the Sound